[SalesForce] Validation Rule stops Process Builder to fire

I have a Process Builder and a Validation Rule on the Opportunity Object.

The Validation Rule is meant to stop the users from modifying an Opportunity once Closed Won, apart from Admins.

AND( ISPICKVAL(PRIORVALUE(StageName),"Closed Won"), CASE($Profile.Name, "ProfileName1",1, "ProfileName2",1, 0)=0 )

And the Process Builder is checking if "[Opportunity].IsClosed = TRUE, and updates the Close Date = TODAY().

Error message:

The flow tried to update these records: null. This error occurred:
FIELD_CUSTOM_VALIDATION_EXCEPTION

Both the Process Builder and the Validation Rule work fine, but activated separately.

Is there a way to stop the users from modifying the Closed Won Opportunity, but allow the process to change the Close Date for the users?

Thanks.

Best Answer

You have two options,

  1. You can create a WF rule to update "Close Date" on Opportunity, Unlike PB, WF rule field update doesn't trigger validation rule (as per order of execution where as process builder updates are enforced to evaluate validation Rules)

  2. You can create a field "exclude_pb__c" and add ischanged condition on this field in you validation rule. You should also update this field from your PB(see image attached..). You still need to give edit access to exclude_pb__c for the profiles mentioned in the pb and hide this field from the layout so they will not be able to modify this field.

AND( 
ISPICKVAL(PRIORVALUE(StageName),"Closed Won"), 
CASE($Profile.Name, 
"ProfileName1",1, 
"ProfileName2",1, 0) = 0,
NOT(ISCHANGED(exclude_pb__c))
 )

enter image description here

of the two, I recommend first option.

Related Topic