Validation rule to bypass the process builder - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
SFASFA 

Validation rule to bypass the process builder

Hi All,
We have a Process that creates a new child record based on the Parent (account) name and owner.

On the child object we have a validation rule that prevents other record owners to edit these records except their own.  

The validation rule we have at present is as follows :

if(isnew(), Account_Owner__r.Id = $User.Id, not(ischanged
(LastModifiedDate ))&& Account_Owner__r.Id <> $User.Id)

This works on existing records, however when a new Account is created we get the following error :

Errorcaused by element : FlowRecordCreate.myRule_1_A1
caused by: UPSERT --- UPSERT FAILED --- ERRORS : (FIELD_CUSTOM_VALIDATION_EXCEPTION) Only the Owner can edit this record. Contact the owner to make any changes. --- for SFDC record with ID : null

Any suggestions ?
Deepak AnandDeepak Anand
An easy way would be to create a New Field on the Contact Object say - 
  1. Label: Bypass Rule
  2. Type: Checkbox
  3. Establish Field Level Security for all Profiles
  4. But Don't put them on the Page Layout
Back when you're creating the Record, simply set the Field to TRUE like this - 
[Contact].Bypass_Rules__c <= TRUE
Then modify the VR like as below - 
Bypass_Rules__c <> TRUE &&
if(isnew(), Account_Owner__r.Id = $User.Id, not(ischanged
(LastModifiedDate ))&& Account_Owner__r.Id <> $User.Id)
Abhishek JainAbhishek Jain
Doesn't works. Any other suggestions?