質問

Can anyone help me on steps to associate the default approval workflow to a SharePoint Library through CSOM ?

Update: When i call ennumeratedefinitions(true) on the workflowservices manager, it only gives the collection of SP13 Workflows. The 2010 Approval WF is not getting intialize.

役に立ちましたか?

解決 2

To add OOTB 2010 workflow to SharePoint List by CSOM . Get the List of SharePoint 2010 Workflow Templates by using the below method

webObj.WorkflowTemplates

I needed the Approval workflow. So i get it by its name after finding out in previous method.

$wfApprovalWFTemplate = webObj.WorkflowTemplates.GetByName("Approval - SharePoint 2010")

Note:

When getting the list of workflows using the Workflow Service Manager Class will return only all those WF's created by SP2013 . i.e Through Workflow Manager.

Create a Workflow Association info

$wfassociationInfo = New-Object Microsoft.SharePoint.Client.Workflow.WorkflowAssociationCreationInformation;
$wfassociationInfo.Template = $wfApprovalWFTemplate;
$wfassociationInfo.Name = "Document Approval"
$wfassociationInfo.TaskList ="#Task List to Assign"
$wfassociationInfo.HistoryList = "#WF History List to Assign"

Associate to the Document Library where you want the approval WF to be added .

Write-Host "Create a new Workflow Associationg with the Neccesary information."
$wf = $listWFToAdd.WorkflowAssociations.Add($wfassociationInfo)
$wf.AutoStartChange = $true
$wf.AutoStartCreate = $true
$wf.AssociationData = $customAssociationData //XML data to store WF Options--You can loop through and get this value from existing workflows to get the structure and settings done.
$wf.Update();

他のヒント

Basically you need to set EnableModeration = true.

var ctx = new SP.ClientContext(siteUrl);
var web = ctx.get_web();
var list = web.get_lists().getByTitle('Your list');
list.set_enableModeration(true);
list.set_enableMinorVersions(true);
list.set_defaultContentApprovalWorkflowId("guid");
list.update()
ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top