2

Continuing from my previous call for help - SharePoint 2013 Reusable workflow doesn't pick up fields in a different site collection

I assume you can associate SharePoint 2013 workflows with content types: enter image description here

After I move the reusable workflow to another site collection, how can I re-associate it with a content type in that site collection. I am currently using PowerShell to associate it with a list but that doesn't seem to work very well.

> $wfm = New-object
> Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($Web)
> $defSevice = $wfm.GetWorkflowDeploymentService() $wfDefs =
> $defSevice.EnumerateDefinitions($false) $wfDef = $wfDefs | where
> {$_.DisplayName -eq $WorkflowName}
> 
> $wfsubService = $wfm.GetWorkflowSubscriptionService()
> 
> $sub = New-object
> Microsoft.SharePoint.WorkflowServices.WorkflowSubscription
> $sub.DefinitionId = $wfDef.Id $sub.Enabled = $true $sub.Name =
> $wfDef.DisplayName
> 
> $startOptions = New-Object
> "System.Collections.ObjectModel.Collection[System.String]"
> $startOptions.Add("WorkflowStart") $sub.EventTypes = $startOptions
> 
> $sub.SetProperty("HistoryListId", $HistoryListId)
> $sub.SetProperty("TaskListId", $TaskListId)
> 
> $wfSubService.PublishSubscriptionForList($sub, $ApprovalListId);

Searched the intrawebz, but can't seem to find a solution on how to associate reusable workflows with content types. Can anyone shed any light on this? Proper ways or workarounds are welcome. Thanks.

1

From MSDN: “Unlike previous versions, SharePoint 2013 does not support workflows that are scoped to a content type (SPContentType). However, the messaging infrastructure is extensible, so it can support any arbitrary scope. As a developer, you can set the EventSourceId property on a given WorkflowSubscription instance to any guid. You can then use that EventSourceId value to call PublishEvent(Guid, String, IDictionary<String, Object>), which triggers a new workflow instance of the specified WorkflowSubscription.”. I haven't found a workaround either. Case closed.

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.