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?


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))
| improve this answer | |
  • 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 '15 at 14:27
  • You should still be able to do it. See my updated answer. – Daniel Hoechst Jul 26 '15 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.