locked
Automatically create links to project site lists in PDP RRS feed

  • Question

  • Hi there,

    I'm in the middle of a PS2013 deployment & customization and my client would like to have links above the project schedule leading to the lists of the project site (the custom project site has plenty of custom lists).

    Creating a link leading to the project site itself is easy (using "javascript:PDPInfrastructure.NavigateWSSPage(0,true)" as a target of the link), but not enough to lead directly to the lists.

    I tried to use an Excel sheet with a pivot table containing all the projects sites URLs, along with a slicer, configured it with a parameter on the file to get the ProjUid in the URL of the PDP with a URL Query Webpart : that didn't work (for some reason, the Excel sheet doesn't accept the filter even if ProjUid's are matching).

    So I did the last thing I could : creating on-the-fly links with Javascript, using the name of the Project displayed in the menu.
    But of course, if the Project Manager changes the name of its project and not the URL of the project site, the links are broken.

    So it works, but it's not perfect; it's better than nothing though. For now, the client tries to update the project site links within the PWA settings when a project manager reports broken links, but that's more of a temporary solution. I am sure that I could use the ProjUid in the PDP's URL to create proper links.

    Does someone knows how I could achieve that ? Or, even better, would it be possible to create project sites with the ProjUid in place of the name of the project ?

    Thanks in advance for your answers.

    Thursday, January 26, 2017 2:02 PM

Answers

  • Hi again,

    Well, guess what -- thanks to the "top related threads" on the side of my own thread, I found a perfect solution. Thank you Paul Mather !

    I used this script and edited it to match my needs, as it gave me the project site URL using the ProjUid :

    https://pwmather.wordpress.com/2015/05/12/projectonline-projectserver-2013-access-sharepoint-lists-on-pdps-javascript-jquery-office365/

    If anyone is interested, here is the complete code (all credits goes to PWMather) :

    	<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"></script>
    	<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
    	<script type="text/javascript" src="/_layouts/15/sp.js"></script>
        <script type="text/javascript" src="/_layouts/15/ps.js"></script>
    	
    	
    <div id="divMessage">
        <br/>
        <span id="spanMessage" style="color: #FF0000;"></span>
    </div>
    	
    <div id="buttons">
        <a id="lienstatutmensuel" href="">Statut mensuel</a> | <a id="lienobjectifs" href="">Objectifs</a> | <a id="lienindicateurs" href="">Indicateurs</a> | <a id="liendepenses" href="">Dépenses</a> | <a id="lienproblemes" href="">Problèmes</a>
    </div>	
    	
    <script type=text/javascript>
    var urlStr = unescape(window.location)
    if (urlStr.toLowerCase().indexOf('projuid')>=0) {
    var projUid = urlStr.substr(urlStr.indexOf("=")+1,36) 
    }
    else {
    	$get("spanMessage").innerText = "Not available in this context. Not a Project Server Project Detail Page or project associated";
    }
    </script> 
    
    <script type="text/javascript">
    
    $(document).ready(function () {
    GetProjects();
    });
    
        var projects;
        SP.SOD.executeOrDelayUntilScriptLoaded(GetProjects, "PS.js");
    
        function GetProjects() {
            var projContext = PS.ProjectContext.get_current();
            projects = projContext.get_projects();
            projContext.load(projects, 'Include(Name, Id, ProjectSiteUrl)');
            projContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);
        }
        function onQuerySucceeded(sender, args) {
            var projectEnumerator = projects.getEnumerator();
    		var proj;
            while (projectEnumerator.moveNext()) {
                var project = projectEnumerator.get_current();
    
    				if (project.get_id() == projUid) {
                      proj = project;
    				}
    		}
    			projSiteUrl = proj.get_projectSiteUrl();
    			
    			document.getElementById("lienstatutmensuel").setAttribute("href", projSiteUrl + "/Lists/Rapport de statut mensuel");
    
    			document.getElementById("lienobjectifs").setAttribute("href", projSiteUrl + "/Lists/Objectifs");
    
    			document.getElementById("lienindicateurs").setAttribute("href", projSiteUrl + "/Lists/Indicateurs");
    
    			document.getElementById("liendepenses").setAttribute("href", projSiteUrl + "/Lists/Dpenses");
    
    			document.getElementById("lienproblemes").setAttribute("href", projSiteUrl + "/Lists/Issues");
    			
        }
        function onQueryFailed(sender, args) {
            $get("spanMessage").innerText = 'Request failed: ' + args.get_message();
        }	
    	
     </script>


    • Edited by R. Brunel Thursday, January 26, 2017 3:18 PM
    • Marked as answer by R. Brunel Thursday, January 26, 2017 3:19 PM
    Thursday, January 26, 2017 3:18 PM