i am associating a custom workflow to a library using csom. How do i select checkbox : Start this workflow to approve publishing a major version of an item using csom.

  • Are you using 2010 or 2013 workflow? Jun 11, 2016 at 3:57

2 Answers 2


Because you are using a custom workflow, I assume you have an Start Approval Process action in your workflow. In this scenario, you need to do two things:

  • In the workflow just before the "Start Approval Process" action set the EnableContentApproval workflow variable to Yes. Note that this workflow variable is automatically created when you add the "Start Approval Process" action to your workflow.
    enter image description here

  • Then using CSOM (or PowerShell) set the DefaultContentApprovalWorkflowId property of the SPList class to the id of the workflow association.
    Since you are using CSOM to associate the workflow with a library, then your code should give you back an SPWorkflowAssociation object which contains the id of the workflow association. You can also get the workflow id by looping through the workflow associations of your list (see SPList.WorkflowAssociations) and checking if the workflow name matches one of the associations.


The workflow association id changes every single time you re-associate the workflow with the library, therefore you have to also update the DefaultContentApprovalWorkflowId property of the library.

  • Doubting if SPList.WorkflowAssociations will work with 2013 workflows! :) Jun 10, 2016 at 14:22
  • Also it is worth using a feature activated event receiver to associate the workflow and perform these steps. Jun 10, 2016 at 14:23
  • @Nisarg, I assumed he deployed a workflow created using the 2010 platform, not 2013 platform. As far as I know, you don't have the "Start this workflow to approve publishing a major version of an item" in workflows created using the 2013 workflows. This option is available for out-of-the-box approval workflows and for 2010 workflows that use the "Start Approval Process" action.
    – Mihail
    Jun 10, 2016 at 14:38
  • Never used it, but I have seen the menu on UI..let me come back to this Jun 11, 2016 at 3:58
  • Yes Nisarg, i have tired earlier with 2013 workflow but publishing is not available there. Now i am extending the approval 2010 workflow
    – MJaiswal
    Jun 11, 2016 at 5:03

Thank you for the comments i have got the solution too. below is my code

            WorkflowTemplate wfTemplate = web.WorkflowTemplates.GetByName(workFlowName);
            var wfc = new WorkflowAssociationCreationInformation();
            wfc.HistoryList = web.Lists.GetByTitle("Approval Workflow History");
            wfc.Name = "Test Approval Workflow";
            wfc.TaskList = web.Lists.GetByTitle("Approval Tasks");
            wfc.Template = wfTemplate;

        WorkflowAssociation wf = list.WorkflowAssociations.Add(wfc);
        wf.AllowManual = false; 
        wf.AutoStartChange = false; 
        wf.AutoStartCreate = false; 
        wf.Enabled = true;            

        if (null != wfTemplate)
            list.EnableModeration = true;
            list.EnableMinorVersions = true;
            list.DefaultContentApprovalWorkflowId = wf.Id;               


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.