Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Programmatically create Workflow Stages in SharePoint 2013 using CSOM

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 481
    Comment on it

    For creating Stages using CSOM, we have to use StageCreationInformation.

    1. First of all, assign basic information to Stage.

    Microsoft.ProjectServer.Client.StageCreationInformation stageInfo  = new Microsoft.ProjectServer.Client.StageCreationInformation();
    stageInfo.Behavior = Microsoft.ProjectServer.Client.StrategicImpactBehavior.ReadOnly;
    stageInfo.CheckInRequired =false;
    stageInfo.Description ="Test Description";
    stageInfo.Id = new Guid();
    stageInfo.Name ="Test";
    stageInfo.WorkflowStatusPageId ="Project Detail Page id related to this stage";
    stageInfo.PhaseId = "Phase id related to this stage";

     

    2. Add Project Detail Page Information to current stage,if any

    List<Microsoft.ProjectServer.Client.StageDetailPageCreationInformation> lstSDPs = new List<Microsoft.ProjectServer.Client.StageDetailPageCreationInformation>();
    Microsoft.ProjectServer.Client.StageDetailPageCreationInformation sdpInfo = new Microsoft.ProjectServer.Client.StageDetailPageCreationInformation();
    sdpInfo.Description = "Test description";
    sdpInfo.Id ="Project Detail Page id related to this stage";
    sdpInfo.Position ="1";
    sdpInfo.RequiresAttention = "false";
    lstSDPs.Add(sdpInfo);
    if (lstSDPs.Count > 0)
        stageInfo.ProjectDetailPages = lstSDPs;

     

    3. Add Custom Field Information to current stage, if any

    List<Microsoft.ProjectServer.Client.StageCustomFieldCreationInformation> lstSCFs = new List<Microsoft.ProjectServer.Client.StageCustomFieldCreationInformation>();
    Microsoft.ProjectServer.Client.StageCustomFieldCreationInformation scfInfo = new Microsoft.ProjectServer.Client.StageCustomFieldCreationInformation();
    scfInfo.Id = new Guid();
    scfInfo.ReadOnly = true;
    scfInfo.Required = true;
    lstSCFs.Add(scfInfo);
    if (lstSCFs.Count > 0)
        stageInfo.CustomFields = lstSCFs;

     

    4. In the last,create Stages with all the above details

    Microsoft.ProjectServer.Client.Stage newStage = projectContext.Stages.Add(stageInfo);
    projectContext.Stages.Update();
    projectContext.ExecuteQuery();

    Hope this information will help you.

    Thanks

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: