如何在SharePoint对象模型(SP 2010)中将工作流与给定列表关联?
我已经能够关联工作流,但配置设置没有保存回SharePoint。换句话说,基本的WorkflowAssociationCreationInformation
被保存回了SharePoint,但使用WorkflowAssociation
进行的任何进一步配置设置都没有保存。
以下是我正在使用的代码:
var context = new ClientContext( url );
Web site = context.Web;
var query = context.LoadQuery( site.WorkflowTemplates.Where( x => x.Name == "My Template Name" ) );
context.ExecuteQuery();
WorkflowTemplate wfTemplate = query.Single();
var wfc = new WorkflowAssociationCreationInformation();
wfc.HistoryList = site.Lists.GetByTitle( "Workflow History" );
wfc.Name = "My Workflow Name";
wfc.TaskList = site.Lists.GetByTitle( "Tasks" );
wfc.Template = wfTemplate;
List list = site.Lists.GetByTitle( "List Name" );
WorkflowAssociation wf = list.WorkflowAssociations.Add( wfc );
wf.AllowManual = false; // is never updated
wf.AutoStartChange = false; // is never updated
wf.AutoStartCreate = true; // is never updated
wf.Enabled = true; // is never updated
string assocData = GetAssociationXml(); // internal method
wf.AssociationData = assocData; // is never updated
context.Load( wf );
context.ExecuteQuery(); // does not update the SP workflow with any of the new wf settings