Using the SharePoint object model (SP 2010), how can you associate a workflow with this list?
I managed to bind the workflow, but the configuration settings do not return to SharePoint. In other words, the base is WorkflowAssociationCreationInformationsaved back to SharePoint, but no additional configuration settings WorkflowAssociationare saved using .
Here is the code I was working on:
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;
wf.AutoStartChange = false;
wf.AutoStartCreate = true;
wf.Enabled = true;
string assocData = GetAssociationXml();
wf.AssociationData = assocData;
context.Load( wf );
context.ExecuteQuery();
source
share