1

I have Two business requirements

1) Leadership team asked me to prevent updating of Sales Stages manually

2) Sales Stages should be updated as result of Logging of Activities

So, I came with following solution

First I have written Validation Rule, which is

AND( 
NOT(ISNEW()), 
ISCHANGED(StageName) 
)

this rule is working fine, nobody can modify sales stages anymore.

Now off to Process Builder

  • Object = Task
  • Criteria = Set Conditions

Conditions are

[Task].Status = Picklist Value = Completed

[Task].WhatID(related to) = starts with = 006 (opportunity object key prefix)

[Task].Subject = String = Call

Immediate Action

Update Records

  • Choose Related opportunity record

Criteria for updating record

Updated Records Meet all Conditions

stage = picklist = prospecting (1st stage)

Set New Field Values

Stage = picklist = Contacted (2nd Stage)

My process builder is working fine too...just that i have to disable validation rule otherwise process fails to execute.

Kindly guide me as to how to achieve these objectives.

Kind Regards Prashant

2 Answers 2

3

Follow below steps to bypass validation rule in process builder:-

Implement a field which allows bypassing validation rules for Processes, on Opportunity, have a checkbox field BypassValidationForProcessBuilder__c, default unchecked, not shown on the Page Layout.

Adjust your Validation Rule to:

AND( NOT(Opportunity.BypassValidationForProcessBuilder__c) ,
NOT(ISNEW()), 
ISCHANGED(StageName) 
)
  • In your Process, in the immediate action block, first, use a record update for the concerned Opportunity record to set our Bypass field to TRUE. Within the same immediate action block, you can now have an action to update the stage name, use as many actions as needed. Then at the end have another update action to set the Bypass field back to FALSE. Within one immediate action block, the actions are done in order and separately.
  • By setting the flag back to false, you are making a field update. This will cause validation rules with boolean checkboxes such as Opportunity.BypassValidationForProcessBuilder__c = false to then make the validation rule true.
  • Alternatively, you could add Opportunity.BypassValidationForProcessBuilder__c = false && !ISCHANGED(Opportunity.BypassValidationForProcessBuilder__c) to the validation rule to bypass it.

reference:- https://help.salesforce.com/articleView?id=000247715&type=1

Hope it helps You.

0
0

This can be done in 2 ways:

A) Using Standard SF OOTB functionality:

  1. Create a Picklist Field on Opportunity, Status_Change_Reason__c, with values 'Manual' and 'Task Update'. Hide it from Pagelayouts so that nooone can manually edit it.
  2. Update your validation rule like below

    AND( NOT(ISNEW()), AND(ISCHANGED(StageName),NOT(ISPICKVAL('Status_Change_Reason__c','TASK Update')) )

  3. . In Process Builder when you update Opportunity, also Make Status_Change_Reason__c as TASK Update . This will make sure you bypass the Validation rule.

  4. Now, You want to enable validation rule again right so that next time someone tries to change status it shouldnt allow. Create a new Process Builder on Opportunity that runs when StStatus_Change_Reason__c is TASK Update and then updates record as blank.

B) Using Apex Trigger: You can implement validation rule Trigger in Apex. And can use static variables to bypass your rule when needed.

1
  • Hi Pranay, thanks for the solution advise, I am confused on how to update opportunity as task update, when process builder does not give any option to use this kind of capability? kindly help i am very confused right now Regards Commented Sep 7, 2018 at 15:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .