1

I try to create a new EPT (project server 2013) using C# CSOM library. But It has following error occurred.

"PJClientCallableException: EnterpriseProjectTypeInvalidCreatePDPUid"

Couple of article tell to change the "IsCreate=true". But it does not success for me. Here is the code what I have done.

public void CreateEnterpriseProjectType(Guid eptGuid, string eptName, string eptDescription)
    {
        ProjectContext pwaContext = new ProjectContext(this.PWA_URL);

        EnterpriseProjectTypeCreationInformation eptData = new EnterpriseProjectTypeCreationInformation();

        eptData.Id = eptGuid;
        eptData.Name = eptName;
        eptData.Description = eptDescription;
        eptData.IsDefault = false;
        eptData.IsManaged = true;
        eptData.WorkspaceTemplateName = "PROJECTSITE#0";
        eptData.ProjectPlanTemplateId = Guid.Empty;
        eptData.WorkflowAssociationId = Guid.Empty;
        eptData.Order = 4;

        List<ProjectDetailPageCreationInformation> projectDetailPages = new
        List<ProjectDetailPageCreationInformation>() { 
            new ProjectDetailPageCreationInformation() { 
                Id = pwaContext.ProjectDetailPages[1].Id, IsCreate = true } 
        };
        eptData.ProjectDetailPages = projectDetailPages;

        pwaContext.Load(pwaContext.EnterpriseProjectTypes);
        pwaContext.ExecuteQuery();
        EnterpriseProjectType newEpt = pwaContext.EnterpriseProjectTypes.Add(eptData);
        pwaContext.EnterpriseProjectTypes.Update();
        pwaContext.ExecuteQuery();
    }

Can anyone explain the issue or provide the working code part.

Udhay Titus
  • 5,761
  • 4
  • 23
  • 41

1 Answers1

0

I would like to suggest the following:

Define an enterprise project type:

string basicEpt = "Enterprise Project"; // Basic enterprise project type.
int timeoutSeconds = 10;  // The maximum wait time for a queue job, in seconds.

And then, when you create the new project, work like this:

ProjectCreationInformation newProj = new ProjectCreationInformation();

            newProj.Id = Guid.NewGuid();
            newProj.Name = "Project Name";
            newProj.Description = "Test creating a project with CSOM";
            newProj.Start = DateTime.Today.Date;


            // Setting the EPT GUID is optional. If no EPT is specified, Project Server  
            // uses the default EPT. 
            newProj.EnterpriseProjectTypeId = GetEptUid(basicEpt);

            PublishedProject newPublishedProj = projContext.Projects.Add(newProj);
            QueueJob qJob = projContext.Projects.Update();

            // Calling Load and ExecuteQuery for the queue job is optional.
            // projContext.Load(qJob);
            // projContext.ExecuteQuery();
            JobState jobState = projContext.WaitForQueue(qJob, timeoutSeconds);

When the last line of that piece of code ends, the project must be created and published in order to define tasks or whatever.

I don't know what is happening to your code, seems great.

Hope it helps to you,

Marc Lluis
  • 61
  • 7
  • I found that with your code, the Project is still created as an Enterprise Project no matter what basicEpt you specify... Therefore only the administrator can use the site, until it is manually changed,. do you know how to change this? – Crezzer7 Oct 10 '16 at 14:09
  • I think this is a SharePoint issue. If I understand your question, do you mean to have access into PWA for other different users not admins? – Marc Lluis Oct 11 '16 at 08:53
  • I have posted a question here to further explain what I mean: http://stackoverflow.com/questions/39953710/creating-a-project-online-using-c-sharp-for-sharepoint , but basically yes, when the project is created, the Enterprise Project Feature needs de-activating manually. I want this done on creation. (PWA Settings -> Connected Sharepoint Sites) is where this option is. Thanks for replying also – Crezzer7 Oct 11 '16 at 09:21