I have a junction object which has a master detail relationship to account and market. This junction object can only be created from account. When user clicks new, Account will already be prefilled but user can only add a market if city field on market,which is a multiselect, contains the city selected on the account object otherwise it throws an error. How can i compare two lookup fields on insert?

1 Answer 1


You can do this with a validation rule. Your formula for your validation rule will probably be something like

Account.BillingCity <> Market__r.City__c

Edit for multi-select picklist:

NOT(CONTAINS(Market__r.City__c, Account.BillingCity))
  • I should have added that the city field on market is a multiselect hence i was not able to use the validation rules
    – SfdcNewbie
    Jul 26, 2015 at 14:27
  • You should still be able to do it. See my updated answer. Jul 26, 2015 at 14:36

You must log in to answer this question.

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