Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Creating EPT in project online using CSOM

    • 0
    • 0
    • 0
    • 0
    • 2
    • 0
    • 0
    • 0
    • 929
    Comment on it

    Hello Reader,

    The following code is used to create a new Enterprise Project Type(EPT):

    1. public void CreateEnterpriseProjectType(Guid eptGuid, string eptName, string eptDescription)
    2. {
    3. ProjectContext projectContext = new ProjectContext("http://serverName/pwaName");
    4. // for project online authentication
    5. SecureString securePassword = new SecureString();
    6. foreach (char ch in "adminPassword")
    7. securePassword.AppendChar(ch);
    8. SharePointOnlineCredentials sharePointOnlineCredentials = new SharePointOnlineCredentials("adminUsername", securePassword);
    9.  
    10. projectContext.Credentials = sharePointOnlineCredentials;
    11.  
    12. projectContext.Load(projectContext.EnterpriseProjectTypes);
    13. projectContext.Load(projectContext.ProjectDetailPages);
    14. projectContext.ExecuteQuery();
    15.  
    16. EnterpriseProjectTypeCreationInformation eptInfo = new EnterpriseProjectTypeCreationInformation();
    17.  
    18.  
    19. eptInfo.Id = eptGuid;
    20. eptInfo.Name = eptName;
    21. eptInfo.Description = eptDescription;
    22. eptInfo.IsDefault = true;
    23. eptInfo.WorkspaceTemplateName = "PROJECTSITE#0";
    24. eptInfo.ProjectPlanTemplateId = Guid.Empty;
    25. eptInfo.WorkflowAssociationId = Guid.Empty;
    26. eptInfo.Order = 1;
    27.  
    28. List<ProjectDetailPageCreationInformation> projectDetailPages = new List<ProjectDetailPageCreationInformation>() {new ProjectDetailPageCreationInformation() { Id = projectContext.ProjectDetailPages[1].Id, IsCreate = false }};
    29. eptData.ProjectDetailPages = projectDetailPages;
    30.  
    31. EnterpriseProjectType newEpt = projectContext.EnterpriseProjectTypes.Add(eptInfo);
    32. projectContext.EnterpriseProjectTypes.Update();
    33. projectContext.ExecuteQuery();
    34. }

    I hope, it helps.

 2 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: