0

Workflows can be set to trigger on item created, item updated, manually and etc.

I have a workflow attached to a list which is by default set to be triggered on item create event. Using powershell I migrate some data to this list. So i need to change the settings of existing workflow not to start on item created event and set it to trigger on item created after i migrate my data.

how to update this property\ setting of workflow using powershell. enter image description here

0

I haven't done this in powershell but I expect that you can use the same classes and methods. If it's a SharePoint 2013 workflow you can query the workflows for a list using "EnumerateSubscriptionsByList" from "WorkflowSubscriptionService" class and change EventType property which is used to indicate the event on which the workflow should start. Here is a related post and question with code examples for powerhshell:

SharePoint 2013 Reusable workflow doesn't pick up fields in a different site collection

https://jesperarnecke.wordpress.com/2014/04/02/sharepoint-2013-workflow-management-starting-a-workflow-using-powershell/

  • Workflow attachment to a list can be done no issue. The problem i have is how to change a property and how to apply changes (update Workflow Subscription service\ list \ web) – 007ruwan May 30 '17 at 8:32
  • Updating is possible by getting the subscription, updating the properties and publishing it again (PublishSubscriptionForList). – Suleyman May 30 '17 at 8:38
  • $workflowServiceManager = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web) $workflowSubscriptionService = $workflowServiceManager.GetWorkflowSubscriptionService() $wf = $workflowSubscriptionService.EnumerateSubscriptionsByList($list.ID) | Where-Object {$_.Name -eq $workflowName} $wf.SetProperty("EventTypes", 'ItemUpdated'); $workflowSubscriptionService.PublishSubscriptionForList($wf,$list.ID); it did not work – 007ruwan May 30 '17 at 11:07
  • Did you check what kind of input is expected for EventType? There is a property called EventType (at least in CSOM) so you don't have to use SetProperty. Here is an example of how EventTypes should be supplied: dev.office.com/sharepoint/docs/general-development/…. Also make sure to perform ExecuteQuery after publish. – Suleyman May 30 '17 at 11:23
  • Its pure powershell i'm working on. So no CSOM or ExecuteQuery. – 007ruwan May 30 '17 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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