tchock
tchock

Reputation: 245

Issue with workflow and validation rule (tripping validation) -- issue of recursion?

I'm having more issues that I'd expect trying to add a validation rule to contacts. The issue is that I'm experiencing workflow creep.

I rely on process builder and flows to keep certain objects in sync. Let me give you an example, say I have a contact with two flags: mailing and shipping. Let's also say I have another object called contact role, which also has flags for billing and shipping. I have workflows that keep these flags in sych, so if mailing is checked/unchecked on one record, it will run a flow to update the related record (contact to contact role and vice versa). Now enter the validation role. I've added a validation role that will trigger when the contact status is "inactive" and either one of these checkboxes are checked.

The issue I seem to be having is that if I am to uncheck both of these on a contact and set status to inactive, the validation rule causes a workflow error because the updates to the flags and updating of the related records is not done at once; there are two separate flows. So the first thing to occur is that the mailing checkbox is unchecked, and its related record is unchecked. Then I get the workflow error, due to I'm assuming the record saving with the mailing checkbox still checked on the record.

My assumption would be that the validation rule would not fire until ALL workflows have finished. Is this not the case? I also question whether the recursion setting on the workflows could be the culprit here. Obviously if ALL workflows finish before the validation runs, it should pass as both checkboxes should be unchecked in the final state.

Upvotes: 0

Views: 408

Answers (1)

nochum
nochum

Reputation: 795

Validation rules are processed well before any workflow rules are processed. The order of processing precedence is documented is this Knowledge Article and the Apex Developer Guide

Upvotes: 0

Related Questions