none
project server 2010: obtaining the guid of a template RRS feed

  • Question

  • Hi,

    I need to use the project.CreateProjectFromTemplate method in my program but this method takes the template guid as a parameter. How can I obtain the template guid?

    Regards,
    George

    Monday, March 28, 2011 10:10 AM

Answers

  • Hi George,

    This code snippet shows how to get the GUID

                    const string PROJECT_SERVER_URI = "http://ServerName/ProjectServerName/";
                    const string PROJECT_SERVICE_PATH = "_vti_bin/psi/project.asmx";
                    const string QUEUESYSTEM_SERVICE_PATH = "_vti_bin/psi/queuesystem.asmx";
                    // Set up the web service objects.
                    ProjectWebSvc.Project projectSvc = new ProjectWebSvc.Project();
                    ProjectWebSvc.ProjectDataSet projectDs = new ProjectWebSvc.ProjectDataSet();
                    projectSvc.Url = PROJECT_SERVER_URI + PROJECT_SERVICE_PATH;
                    projectSvc.UseDefaultCredentials = true;

                    // Get a a list of all templates
                    ProjectWebSvc.ProjectDataSet readTemplateDs = projectSvc.ReadProjectStatus(Guid.Empty, ProjectWebSvc.DataStoreEnum.PublishedStore, String.Empty, (int)PSLibrary.Project.ProjectType.Template);
                   
                    //  Get a specific template
                    string templateName = "MyProjectTemplate"
                    ProjectWebSvc.ProjectDataSet readTemplateDs = projectSvc.ReadProjectStatus(Guid.Empty, ProjectWebSvc.DataStoreEnum.WorkingStore, templateName, (int)PSLibrary.Project.ProjectType.Template);
                    // you can find the template ID  in: readTemplateDs.Project[0].PROJ_UID
                    
                    // Create the new project on the server and get its GUID.
                   
                    Guid newProjectGuid = projectSvc.CreateProjectFromTemplate(readTemplateDs.Project[0].PROJ_UID, projectName);

    Regards, J
    • Marked as answer by geo_d Monday, March 28, 2011 1:28 PM
    Monday, March 28, 2011 1:10 PM