"The workflow must be in a published state." while trying to execute CRM 2011 workflow

I need to run CRM 2011 workflow from .Net. I looked at an example CRM 2011 SDK that uses the message ExecuteWorkflowRequest. The example works, this is a good start, but the sample also creates the CRM workflow element that it runs.

I am trying to execute a workflow element that already exists. But I keep getting the error "Workflow must be in publishing state." although I activated the workflow.

I tried to execute the same workflow element as with the CRM 4.0 SDK, and it works fine. But I cannot use this SDK with how the system works, since I need to execute a workflow element, creating a custom workflow workflow.

Thank you in advance

+5
source share
3 answers

For each created workflow, two workflow objects are stored in the CRM 2011 database. The workflow object has an attribute called Type. Type == 1 published. Type == 2 is a draft. When you request a workflow, be sure to include the type value in the where clause.

var workflow = context.CreateQuery("workflow").FirstOrDefault(w => w.GetAttributeValue<int>("type") == 1 && w.GetAttributeValue<string>("name") == workflowName && w.GetAttributeValue<bool>("ondemand") == true && w.GetAttributeValue<string>("primaryentity") == targetEntityName); 

A sample CRM 2011 SDK code is provided in examples of how to connect to the Organization service.

+15
source

Without creating any workflows, if you get the error message “Workflow must be in publishing state”, you tried to “publish all settings” to find out if this helps?

To do this, click "Settings-> Solutions-> Publish All Settings."

0
source

In my case, my workflow was saved as a process template. Changing it for a process should solve the problem.

enter image description here

0
source

All Articles