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:
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.
Updating the invoice status – the old way
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:
However we found that although this appears to change the entity fields correctly:
… the workflow is just not being triggered
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
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.
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