Dynamics CRM entity status weirdness


Since upgrade of CRM Online to 8.2, we have noticed some strange issues around workflow triggers that are supposed to be fired by the change of a record status.

We have a workflow associated with the Invoice entity that is set to trigger on change of record status:

Workflow trigger settings

The workflow is responsible for setting up various bits of data when we issue an invoice, then flagging to an external integration that the invoice is ready to send to Finance.

We trigger the workflow in a couple of places – in C# code that runs during various automated operations, and in Javascript in response to a manual button click.

Updating the invoice status – the old way

Traditionally we would fire this using a SetStateRequest (C#, Javascript):

Updating the invoice status – the new way

However as that call has been deprecated, we took the opportunity of some other refactorings to migrate to using Update requests.

Using C# and IOrganizationService.Update

First attempt in C# was:

However we found that the workflow was being triggered twice!

The only way we found to stop this happening was to adjust the code so we only update the statuscode attribute:

Using Javascript and REST API PUT

Our first attempt in Javascript mirrored what we had found in C#:

However we found that although this appears to change the entity fields correctly:

Invoice status set correctly after REST PUT call just with status code

… the workflow is just not being triggered

So then we tried in javascript settiing the statecode as well, and the workflow triggers twice again! We restored the javascript to only update status (as per the gist above), and moved on to look at other settings for the process trigger.

Changing the process trigger

We changed the process trigger for the workflow to be “When record fields change” (i.e. update), and filtered only on statuscode

Worflow update trigger
Worflow update trigger filter attribute

I half expected that this might fire initially but that later steps where the workflow calls itself recursively by changing status of the invoice would fail.

First experiment was triggered by using the Javascript button(sending a PUT with only the statuscode). This ran correctly all the way through.

Second experiment was triggered from C# code based on other system actions. That too ran correctly all the way through, with the process only triggered once.

UPDATE – later in testing we started seeing random double triggers on this when the invoice status was changed using Update. Reverting to legacy SetStateRequest (but with the process still triggered on Update) corrected this behaviour. As none of this fits with documentation we assume it is an obscure bug in the platform


Microsoft have made changes to the way entity status interacts with processes.

The Microsoft recommendation is that all code which changes record status should do using updates, not the deprecated SetStateRequest

UPDATE: however from our later tests we consider SetStateREquest to be the safer option on the IOrganizationService

For workflows which are set to trigger on “Record status changes” there appears to be inconsistent behaviour depending on the source of the update (SOAP via the IOrganizationService, or directly to the newer REST API )

From our tests, any workflows which are triggered from “Record status changes” should be modified to fire on “Record fields change”, filtered down to just the status field.

Worflow steps created in the Workflow Designer which call “Set record status” still work, and will still fire triggers that have been modifed as above

Proactive application of technology to business

My interests include technology, personal knowledge management, social change