Showing posts with label workflows. Show all posts
Showing posts with label workflows. Show all posts

Friday, March 6, 2015

Stop workflow with a status of Succeeded, not Canceled

I learned a valuable lesson when working with a workflow recently. There is a difference between Stop workflow with status of: Succeeded and Stop workflow with status of: Canceled. (scroll to the final paragraph if you just want a sentence-long description of each status)



Based on what I had seen elsewhere, the difference in these two workflow statuses was in name only.

In my scenario, I have a workflow set up to create some cases at the creation of an opportunity (or when certain fields change), unless the user who created the opportunity is a particular user. I thought by selecting a status of canceled, I would be able to easily distinguish between instances where the workflow went through all of the steps and instances where the workflow stopped itself on the first step. However, I had a misunderstanding of what changing the status of canceled would do.


Setting the status as canceled was causing business process errors when this users was trying to create opportunities, and it was causing errors for a plug in that we have installed. Changing the workflow to a status of canceled not only stopped the workflow, but it also stopped the event that triggered the workflow. For me, this was unintended behavior.
Essentially, using the status of canceled is a way to cause an error that can be tracked when a certain condition is met. Using the status of completed will stop the workflow from moving any further, but will not prohibit the event that triggered the workflow in the first place.

Wednesday, January 21, 2015

Workflow Waiting Error on Email Creation Step

I ran into an issue while doing some testing today. I had a workflow that I had modified, and I changed the email notification that is created by the workflow to email me. The workflow stayed in a waiting status, and it was stuck at the email creation step. When I opened the system job I found the following error in the details section:
Cannot create the given type without the required parameters.Plugin Trace:[Microsoft.Crm.Workflow: Microsoft.Crm.Workflow.Activities.EvaluateExpression][EvaluateExpression] 
Error Message:Unhandled Exception: Microsoft.Crm.CrmException: Cannot create the given type without the required parameters.   at Microsoft.Crm.Workflow.Services.ExpressionServiceBase.CreateCrmType(WorkflowPropertyType type, Object[] values)   at Microsoft.Crm.Workflow.Services.ExpressionServiceBase.EvaluateExpression(ExpressionOperator expressionOperator, Object[] parameters, Type targetType)   at Microsoft.Crm.Workflow.Activities.EvaluateExpression.Execute(CodeActivityContext context)   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

I found this blog post by Simon Harvey that gives one cause for the error with a fix that worked for me.
Fix: Microsoft.Crm.CrmException: Cannot create the given type without the required parameters.
Basically, this error comes after changing the recipients of an email created by a workflow. Delete all values in the to, cc, and bcc, save (possibly save and close) the email, and add the proper values back into it. 

This worked great for me! Thanks, Simon.