Microsoft Dynamics CRM 2013 Status Reason Transitions – Part 2

Colin Maitland, 17 June 2014

In my previous blog I described the new Status Reason Transitions functionality introduced with Microsoft Dynamics CRM 2013 SP1 and Microsoft Dynamics CRM Online Spring ’14.

In this blog I will demonstrate the behaviour and errors that are displayed when attempting to change the Status and Status Reason of a record to a Status and Status Reason that is not allowed by the Status Reason Transitions configuration for the entity. I will also demonstrate the differences when using Set Field Value, Update Record or Update verses using Set State or SetStateRequest to change the Status Reason. I will be looking at this behaviour using Business Rules, Workflow Processes and Plugin Processes. 

The following are the Status Reason Transitions that have been configured and used from an entity when testing this functionality:




Business Rules

Business Rules do not have a Change State action for changing the Status and Status Reason of a record. The following tests were therefore completed using the Set Field Value action.

When a Business Rule was used to change the Status Reason from Awaiting Review to Published, using a Set Field Value action, the change was permittedHowever, initially no value was displayed for the Status Reason until after the form was refreshed:

  •  Before Business Rule changes Status and Status Reason:

  •  Immediately after Business Rule changes Status Reason: “--" is displayed for the Status Reason because the Published Status Reason is not available in the configured Status Reason Transitions for Awaiting Review

  •  After Form Refresh:

 
When a Business Rule was used to change the Status/Status Reason from Active/Awaiting Review to Inactive/Expired the Status was retained as Active but the Status Reason was set to blank!

In part this is related to the incorrect use of the Set Field Value action in the Business Rule for changing the Status from Active to Inactive. The correct method for changing from an Active to an Inactive Status and vice versa is to use a Change Status action. Business Rules do not have a Change Status action.


Workflow Processes

Workflow Processes cannot be configured to change the Status Reason of records using an Update Record action in a manner similar to a Business Rule’s Set Field Value action.

When a Background Workflow Process was used to change the Status Reason from Awaiting Review to Published, using the Set State action, this resulted in the Workflow Process being set to a Waiting state with the following error displayed at the Set State step:



When a Background Workflow Process was used to change the Status and Status Reason from Active/Awaiting Review to Inactive/Expired, using the Set State action, this resulted in the Workflow Process being set to a Waiting state with the following error displayed at the Set State step:



When these Workflows Processes are changed to, and executed as, Real-Time Workflow Processes a Business Process Error displayed at the Set State step:

The Log File contains the following Error Code and Message: -2147220891; “Entity: new_product does not have valid status code”.


Plugin Processes

When a Plugin Process is used to change the Status and/or Status Reason, using an Organisation Service SetStateRequest, to a new Status and/or Status Reason that is not allowed by the Status Reason Transitions configuration for the entity an Error is displayed:

The Log File contains the following Error Code and Message: -2147160050; Entity: new_product does not have valid status code”.

However, if the Status Reason field is changed using and the Organisation Service Update method then the Status Reason can be changed to a Status Reason, for the current Status, that is not allowed by the Status Reason Transitions configuration for the entity:

  •  Before Plugin executed Update of Status Reason:

   •  After Plugin executed Update of Status Reason:

 
This is the same behaviour as that which occurred when using a Business Rule Set Field Value action.

In conclusion when using a Change Status action in a Workflow Processes or a SetStateRequest in a Plugin Process change of will not be permitted, and an error will be thrown, if the new Status and Status Reason are not allowed. However, if a Set Field Value action in a Business Rule or an Organisation Service Update message in a Plugin Process is used to change the Status Reason to another Status Reason then the Status Reason can be changed to a Status Reason that is not allowed by the Status Reason Transitions configuration for the entity.