Programmatically get Project Site Url in webpart to show on PDP RRS feed

  • Question

  • Hi,

    I have a custom webpart that i have placed on a pdp.  this pdp is associated with the second stage of the first phase.  at this point, my project site is created and i want to show some urls on pdp (for instance i have three document libraries and i want to show the user links to those libraries only).  so my question is how would i get project site url so i can generate the links?  Your help is always appreciated.



    Tuesday, May 8, 2012 11:11 PM


All replies

  • Hi,

    The Project Site URL is available if you call the PSI method WSSInterop-ReadWSSData. This method takes the ProjectUID and returns a data set that includes the Project_Workspace_URL

    Hope this helps,

    Alex Burton
    www.epmsource.com | Twitter
    Project Server TechCenter | Project Developer Center | Project Server Help | Project Product Page

    Tuesday, May 8, 2012 11:45 PM
  • Hi there--

    Apart from Alex's Sound advice, As you said that the site is already created & you want to show the link.
    As an alternate, You can get the project site from Reporting database query:

    [ProjectName] ,
    FROM [dbo].[MSP_EpmProject]

    Once you know that document library path, you may concatenate url to get the exact path of library.

    Hope that helps.

    Thanks, Amit Khare |EPM Consultant| Blog: http://amitkhare82.blogspot.com http://www.linkedin.com/in/amitkhare82

    Wednesday, May 9, 2012 4:49 AM
  • Hi Alex,

    Would i be able to use SP Object Model (SPSite) to get further details on this project site?  I have tried using SPSite with the workspace URL but it fails:

    The Web application at Sample could not be found.

       at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken)
       at Microsoft.SharePoint.SPSite..ctor(String requestUrl)
       at ConsoleApplication1.Program.Main(String[] args) in c:\users\sp_farm_admin\documents\visual studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 33
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()



    Wednesday, May 9, 2012 1:49 PM
  • Fixed.  Thank you all for your advice.  I didn't want to hard code names of libraries so here is what i end up doing:

    - PSI method calls to Wssinterop.asmx and get Project Name from ProjectWSSInfoDataSet.ProjWssInfoDataTable

    - get the current web application using SPContext.Current.Site.WebApplication.  previously i was trying create SPSite instance using the project site URL which was giving the error

    - get the valid SPSite and OpenWeb using project name which returns SPWeb

    now i can loop through all the items in the Folders and create dynamic URLs

    Happy Coding!


    Wednesday, May 9, 2012 5:50 PM
  • When you are working on web part then you need project site URL. Project GUID show in URL when you are working inside the project. Get the guid by query string and find the project site url from below code.

    Get project site url dynamically

    anil gangwar

    Wednesday, June 22, 2016 4:24 AM