Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Workflow Manager 1.0 and publishing workflow definitions

$
0
0

Hi

I've deployed a workflow definition to my site (exported it from an other, but very similar subsite. Both sites are created from my project web template).The workflow is created in SharePoin Designer 2013.

When I create a list workflow by using the Add a workflow option on the list settings my workflow lookups don't work ( list just don't get resolved properly -> known issue)

When I publish my definition ( reusable workflow) in SPD first (don't open any actions/steps in SPD!!!) and then create a workflow instance with Add a workflow things are fine.

My question now is how can I replicate the publish step of my reusable workflow in code. I've tired something like this but it doesn't work (same result as when I don't publish my definition):


var unpublishedWorkflowDefinitions = workflowDeploymentService.EnumerateDefinitions(false);
clientContext.Load(unpublishedWorkflowDefinitions);
clientContext.ExecuteQuery();
foreach (var unpublishedWorkflowDefinition in unpublishedWorkflowDefinitions)
{

 {

  // Re-Publish the Definition

  workflowDeploymentService.PublishDefinition(unpublishedWorkflowDefinition.Id);

  clientContext.ExecuteQuery();


  // Create new subscription


  WorkflowSubscription newSubscription = new WorkflowSubscription(clientContext)

  {
                          DefinitionId = unpublishedWorkflowDefinition.Id,

                                        Enabled = true,

                                        Name = associationName

               };

                                 


  var startupOptions = new List<string>();
                startupOptions.Add("WorkflowStart");

  newSubscription.EventTypes = startupOptions;
         newSubscription.SetProperty ( "HistoryListId", workflowHistoryListId.ToString());

               newSubscription.SetProperty("TaskListId", workflowTaskListId.ToString());
         var result = workflowSubscriptionService.PublishSubscriptionForList(newSubscription, listId);
               clientContext.ExecuteQuery();

 }

}

Any ideas? Iv'e got the feeling that all that I'm after is how to make the publish a workflow definition the same way SPD does publish the reusable workflow.


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>