I have a workflow rule that fired unexpectedly.
The workflow rule was set to evaluate when a record is created, and any time it's edited to subsequently meet criteria
The workflow rule criteria are:
- Case_Worker__c != null
- Type != Billing
- Case Owner = Customer Care (a queue)
This workflow rule fired (causing an email alert to be sent out to some of my company's customers) when I had my intern update the ContactId on the Case
, with no other fields being changed
I was able to reproduce this behavior myself (after making sure that no more of these emails were erroneously sent off to our customers). I was also able to reproduce this issue when updating the AccountId
field on the same Case
record.
After I narrowed the cause down to this workflow rule, I took a look at my org's Case Assignment Rules
and Case Auto-Response Rules
and found nothing that would be setting or overwriting any of the 3 fields included in the workflow rule's criteria.
Why do updates to ContactId
or AccountId
cause this workflow rule to fire?
Edit:
I also checked the 2 triggers I have on Case
(these triggers were inherited, moving everything to my trigger framework is work for my downtime). The only Case
field updated in my triggers is Parent_Account__c
.
After that, I checked every other trigger in my org, as well as every apex class in my org. I was unable to find any instance of any of the 3 fields used in the workflow criteria being altered.
Edit 2:
Here's a minimum viable reproduction.
The prerequisites are:
- Have at least 2 different
Contacts
in the org you are testing this in - Have no mandatory lookup filters on the
Contact Name
(ContactId
is the API name) field. Alternatively, ensure your 2 contacts will meet a mandatory lookup filter - Have no existing workflow rules on
Case
that contain workflow field updates which update theContact Name
(ContactId
) orWeb Email
(SuppliedEmail
) fields - Comment out any portions of triggers or apex that update the
Contact Name
/ContactId
orWeb Email
(SuppliedEmail
) fields - Double check that Case Assignment and Case Auto Response rules won't interfere with the
Contact Name
/ContactId
orWeb Email
(SuppliedEmail
) fields
After that is done
- Create a new workflow rule on
Case
- Set evaluation criteria to
Evaluate the rule when a record is created, and any time it's edited to subsequently meet criteria
- Set the rule criteria to
Case:Web email equals [email protected]
- Set the rule criteria to
- Create a new workflow field update (immediate action)
- Set it to update the
Description
field ofCase
- Use a formula
Description + 'Last workflow field update at: ' + TEXT(NOW())
- Set it to update the
- Don't forget to activate the workflow rule
- Either create a new
Case
, or use an existing one - Populate the
Contact Name
(ContactId
is the API name) field - Update the
Web Email
(SuppliedEmail
is the API name) to[email protected]
- Observe that the Description field has been updated
- Update the
Contact Name
field - Observe that the Description field has been updated again, even though the
Web Email
field has not changed
ContactId
onCase
is one of the last steps in the procedure I wrote for my intern to follow. We were doing a test run in our QA environment. I immediately took responsibility for the issue.