Why are my Dynamic Values sent in an email from a Dynamics 365 Workflow wrong?
Isaac Stephens, 15 June 2020
Recently, I created a Workflow that set a User lookup field on a record and sends an email to a contact. In this email the updated field is used in two different ways; the first is by accessing it directly from the Case - this gives the Full Name of the User. The second way is by using the Related Entities and choosing ‘Evaluated By (User)’ and then selecting the relevant attributes. This is shown below in the email template.
This works fine for the first Dynamic Value “Evaluated By (Case)” and the User’s full name is pulled through and this also worked correctly for the other Dynamic Values if this field was empty before this workflow triggered. However, if the Evaluated By field was populated prior to the workflow being triggered, we would not get the correct values coming through.
If “Old Evaluator” was in the Evaluated By field and the workflow runs and updates Evaluated By to “New Evaluator” the email would come through with the Dynamic Values being set as this:
Evaluated By (Case)
First Name(Evaluated By (User))
Main Phone(Evaluated By (User))
“Old Evaluator’s Number
Primary Email(Evaluatede By(User))
This meant that the email was having a mixture of the post-workflow field and the pre-workflow field. This is clearly an issue as we do not want to send out incorrect data in the emails. This must mean that although the field has been updated, the workflow process has not had enough time to fetch the new record’s attributes and still has the old ones in its cache. Which means when using Related Entity Dynamics Values you will get the incorrect data.
The solution to this was to simply add a Wait Condition before creating and sending the email. The wait condition was set to a duration of 1 minute, which gave enough time for the Related Entity Data to be updated in the background and when the email was sent the correct data was shown.