0

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.

2
  • 1
    Why do you need PB to update "Close Date" field using PB? As per Salesforce Out-of-Box functionality, Close Date will be automatically update when the opportunity stage field is updated with a value associated with "Close" Type (Closed/Won or Closed/Lost). – Veera G Dec 10 '19 at 16:09
  • Hi, As the only time the Opportunity Close Date field changes to today's date is when the user has a Close Date in the future, and they change the status to a Closed/Won stage. As the users don't always keep the Close Date updated, they tend to remain in the past, so when the Opportunity is Closed Won or Closed Lost today, it will have a Close Date from last month. – SSimion Dec 10 '19 at 16:29
1

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.

2
  • Hi Veera, Thanks a lot for coming back to me. I will give this a try and come back to you, if I have any issues. The PB also sets an Opp Name and it also has some scheduled actions email alerts, so that's the reason why I was trying to have them all in one process, but I guess I could just remove the Close Date action group and leave the rest as a PB, or just create a workflow with time-dependent actions for the scheduled actions. I will come back to you. – SSimion Dec 11 '19 at 12:36
  • Hi Veera, I hope you're well. I have just tested it and it works perfectly fine. Thanks a lot for all your help. – SSimion Dec 16 '19 at 11:34
0

Use PRIORVALUE in your validation rule.

Basically, if priorvalue and current value is equal and current value equals to ISWON, stop all updates. If priorvalue is not equal to current value and current value equals isWon let updates happen.

The problem is, user can update records, while changing record to closed won in this case.

Adjust your process builder accordingly.

1
  • Hi, I have used PRIORVALUE in my validation: AND( ISPICKVAL(PRIORVALUE(StageName),"Closed Won"), CASE($Profile.Name, "ProfileName1",1, "ProfileName2",1, 0)=0 ) – SSimion Dec 10 '19 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.