function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Prachi VijayvargiyaPrachi Vijayvargiya 

I have a Workflow, which updates a field to 100. Also there is a validation rule that throws an error each time the value is 100. What will happen in this case.?

Khan AnasKhan Anas (Salesforce Developers) 
Hi Prachi,

Greetings to you!

Salesforce processes rules in the following order:
  1. Validation rules
  2. Assignment rules
  3. Auto-response rules
  4. Workflow rules (with immediate actions)
  5. Escalation rules

Validation Rules fire before workflow rules, so the record has to meet the validation rule criteria before the workflows get a chance to run. So, validation rule will not work when you update the workflow field.

Please refer to the below links which might help you further.

https://help.salesforce.com/articleView?id=fields_validation_considerations.htm&type=5

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
GovindarajGovindaraj
Hi Prachi,

In your case, validation rule will be skipped. 

As per Salesforce execution order,
If the record was updated with workflow field updates, fires before update triggers and after update triggers one more time (and only one more time), in addition to standard validations. Custom validation rules, duplicate rules, and escalation rules are not run again.

Execution order : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm

Please let us know if this helps.

Thanks,
Govindaraj.S
Prachi VijayvargiyaPrachi Vijayvargiya
Hi Anas!
Thanks for the reply.

So say for example, I have a field whose value eneterd is 200. Can you tell me what will happen in this case. Will the value change to 100(workflow)?.
Or the validation will first check(200) accept it, and later the workflow will change it to 100.
Am I right?

Thanks
Prachi
Khan AnasKhan Anas (Salesforce Developers) 
Yes, the value of that field will update to 100.