Serialization Exception In Sandbox Workflow

We recently encountered this error while working on an existing CRM 2011 custom Workflow to make it ready for CRM 2016 online. First, we tested this Workflow on CRM 2016 non-Sandbox mode and it was working fine but when we tried to deploy this Workflow on Sandbox mode, we started getting  the following error:

System.Runtime.Serialization.SerializationException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #5E7698A3

This error seems to be strange, as this is a serialization error but why it was working fine in non-Sandbox mode? When we started doing troubleshooting and debugging the code in Sandbox mode, we found this error was coming because of the following line, as early bound classes were used in this Workflow:

new ConditionExpression(“statecode”, ConditionOperator.Equal, HIMBAP.ProductState.Active);

To avoid this error, we changed this to following, as it is used in the late bound programming model:

new ConditionExpression(“statecode”, ConditionOperator.Equal, 0);

Workflow started working fine in Sandbox mode as well.

Hope it will help someone!!

Ebook Download
View all
Learn
View all