{Observation} Execution context of Real-time workflow

We all know that if we call a child workflow from a parent real-time workflow, it runs in context of that parent workflow but what happens if the trigger for the parent real-time workflow is updated using a custom application outside of CRM?

I had a custom .Net application which used to get values from CRM, send them to SAP and update the return values from SAP back into CRM. The custom application used to trigger as an batch application. There was a real-time workflow configured on update of the fields populated by the .Net application in CRM which internally used to call a child workflow process.

One day issue was reported by the .Net application as “[Microsoft.Xrm.Sdk.OrganizationServiceFault]: This workflow cannot run because one or more child workflows it uses have not been published or have been deleted. Please check the child workflows and try running this workflow again. (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault).”.

As the .Net application used to update the field which then used to trigger the real-time workflow (configured to run “After”) it was not quite obvious behavior for me. I did know that the child workflow was deactivated but my assumption was that the issue will be logged in system jobs and not in .Net application. I was expecting that .Net application will update the field in CRM, after which the parent real-time workflow will trigger which will try to call a deactivated child workflow and fail.

But after digging a bit it was observed that as the parent workflow was configured as real-time it keeps the context with calling .Net application and returns the error back to .Net application. Due to which the .Net application throw an exception. I’m still not sure why, but this is how it works.

Advertisements

DID YOU KNOW? Workflow process throws generic CRM error


Scenario

I have an OOB workflow process developed some time back and activated. Now when I try to open the process, I get generic CRM error (below image). Also the process status is changed to “Draft” automatically. There were no updates made to the process.

Cause

I have seen these issues frequently especially when working with Child Workflow Processes where I have a child workflow called from a Master workflow. If you have a Master workflow calling a child workflow and for some reason the child workflow is activated as “Process Template”, then user gets this error when they try to open the master workflow.

Conclusion

CRM throws generic exception and its status is changed to Draft if it linked/related to a “Process Template” instead of “Process”.

Note

Other common issue faced while working with workflow process is “Invalid Expression” error in “Condition Expression” step. This occurs if the field used in condition expression is either deleted from system or if Value is changed. Once you fix the field/value issue, all conditions in the process are automatically fixed.