function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
raji devi 1raji devi 1 

Validation for lookup field and checkbok

Hi All,

I have contact object with 1 lookup Account name field and create_account__C  checkbox custom field  in it.(I have a trigger on this if check box is checked  account is created, i.e every contact has account record)
My scenario goes in this way-
1. If User selects both the lookup field and check box in detail page and Click on Save, it should throw the Validation Error to select any one of lookup or check box  instead of both
2. if user didnot select lookup field and check box in detail page and click on save , it should throw the validation error to select any one of lookup and check box

Thanks in advance.



 
Best Answer chosen by raji devi 1
AG_SFDCAG_SFDC
Hello,

Try This:

IF((AccountId <> '' &&  create_account__c),True,IF((AccountId == '' && !(create_account__c) ), True,False ) )

Thanks,
AG

All Answers

AG_SFDCAG_SFDC
Hello,

Try This:

IF((AccountId <> '' &&  create_account__c),True,IF((AccountId == '' && !(create_account__c) ), True,False ) )

Thanks,
AG
This was selected as the best answer
rushirushi
Hello,

try the below statement in the validation rule
and(create_account__C  = true, not(ISBLANK(lookup field here ) ))
the error message will e like this: enter either  account lookup value or check box.

Thanks,
rushiE