0

We have 2 objects,Opportunity(Parent) & Opportunity Risk (Child).When Opportunity is craeted,child gets created automatically.When child record is created we are not filling all fields on child records.there are some fields on child objects that needs to be filled by sales rep manually once opportunity is created.so when I navaigte to opportunity then Opportunity Risk and if i try to edit and save it,it thorws the validation message on Opportunity Risk.

I have a requirement inwhich I am updating Sales Person on Opportunity Object by selecting Country.Based on the different country value,different sales rep is assigned.Same Sales Person Field is craeted on Opportunity Risk also. Once the sales person on Opportunity is updated,same is updated on Opportunity Risk.This is working fine on Opportunity Record creation.It gets failed when I have update the existing Opportunity Record by changing the country.It is because we have a existing Validation Rule on Opportunity Risk that executes first and prevent us from Saving the record. Below is the validation Rule.

 OR( AND( 
    RecordType.DeveloperName = 'ABC', 
    TEXT(Related_Opportunity__r.Source__c) = 'RFP', 
    NOT(ISNEW()), 
    ISPICKVAL(RFP_Q1__c, '')))

we had put this validation rule because once we edit Opportunity Risk, RFP_Q1__c needs to be filled.

so when I update the country field,it tries copy new sales person from Opportunity to Opportunity Risk but as I am not providing any value for RFP_Q1__c,it throws validation message. I want to bypass this validation whenever I am changing country and when I am on Opportunity Risk,validation should enforce.

Can someone suggest me how can i bypass validation in such requirement?

0

1 Answer 1

1

The way to think about this is:

  • validation rules can reference field values on the target object (Opportunity_Risk__c), or values that depend on the running user such as Hierarchical custom settings

  • assuming that you are using a trigger or process builder to update the child record once the parent Opportunity is set, then you need to set a value referenceable by the VR before the update of Opportunity_Risk__c and then unset the value before the transaction ends

Whether to use a custom field to do this or a user-level hierarchical custom setting depends on application issues. Custom fields will mean an extra DML update on Opportunity after the children Opportunity_Risk__c are update. If you don't already use hierarchical custom settings, you'll need to create and set a default value for the org level (i.e. don't bypass the VR)

You must log in to answer this question.

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