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
Michael oyebolaMichael oyebola 

Validation rules for two Lookup fields

I created a relationship that links an object to another object .
My scenario goes in this way:
If a user select an account using the lookup search functionality and also wants to search for contact related to that account only by using the lookup funcationality. What validation rules can I use to create the linkage to only have the contact related to that account searched for by using the lookup tool.

Thanks.
George_LiGeorge_Li
Hi Michael, 
Are you looking to "prefiltering" the Contact Lookup with the value entered in the Account Lookup? Or are you looking to validate that the Contact entered is related to the Account? I don't think prefiltering is possible, unless the record has already been saved...

George
Michael oyebolaMichael oyebola
Hi George,
I was looking into "prefiltering" the Contact Lookup with the value entered in the Account Lookup but since this is not possible, what other functionality can we use in saleforce? Apex Trigger?
Ankur Saini 9Ankur Saini 9
Hi Michael, 

try the following steps:

Go to the Object that has these two lookup(Account, Contact) fields--click on Edit link of Contact lookup field--click on Show Filter Settings link--click on insert suggested criteria button--select 1st option and insert (looking like
You have selected:Contact: Account ID
API Name: Contact.AccountIdequalsPosition: Account
API Name: $Source.Account__c)  ----save.

Please let me know if it works.

Thanks
Ankur Saini
http://mirketa.com