Using NOT(ISCLONE()) in a validation rule to allow opportunities to be cloned - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Matthew SolomonMatthew Solomon 

Using NOT(ISCLONE()) in a validation rule to allow opportunities to be cloned

I've been working on transitioning our instance to lightning and have run into a snag. We have the desire to be able to clone opportunities and set a few values on clone. Previously we had been using a URL button to make those updates but updating records in URL buttons no longer works in lightning. 

What I created was a workflow rule that only triggers when a record "ISNEW() && ISCLONE()" and then sets the appropriate values (Stage, RecordType.) When testing I found that we also have a validation rule that doesn't allow me to create opportunities unless it is in a certain stage. So in the example, the workflow should update the Stage to "2 - Qualifying" but because the one I am cloning is already in "3 - Proposing"  the validation rule will not let me save the new record. This is likely because of the order of operations in which Salesforce evaluates automation before inserting new records. 

I've updated the validation rule to include NOT(ISCLONE()) (see below) but it is still triggering the error. Any thoughts on what I need to update would be greatly appreciated. I could also build this using flows but want to see if I can use the standard buttons first. Thanks! 

AND( 
NOT(ISCLONE()), 
ISNEW(), 
NOT(ISPICKVAL(Deal_Type__c, 'Change Order')), 
TEXT(StageName) <> "1 - Discovery", 
TEXT(StageName) <> "2 - Qualifying" 
)
Sunil SarillaSunil Sarilla
Hi Matthew,
one way of doing this
create a custom field and as part of the workflow, populate this field with some value. Do not include this field on the page layouts

Now modify the validation rule as below
AND( 
ISBLANK(Custom_Field__c), 
ISNEW(), 
NOT(ISPICKVAL(Deal_Type__c, 'Change Order')), 
TEXT(StageName) <> "1 - Discovery", 
TEXT(StageName) <> "2 - Qualifying" 
)
Matthew SolomonMatthew Solomon
Sunil, thank you for your response. I tried the method you supplied but it did not work as expected. Because the workflow rule is evaluated after the validation rule that field is not updated in time. Shouldn't the ISCLONE() function work in this scenario though? Thanks again for your help. 
Evan PonterEvan Ponter
I believe you may be affected by this Known Issue:

https://success.salesforce.com/issues_view?id=a1p3A000000IYveQAG

You should subscribe to this to see when a fix is made