I have a lookup field on an object and when a user selects a value in that field and i have throw an error if it does not fulfill certain filter criteria. Since filter criteria does not work on multi select picklist how i can do this?

On the object a i have a field - version which is a picklist.

on object b i have a field version which is a multiselect

Object a has a field which is a lookup to object b and only a record of object b which contains the version on object a as one of the options in the multiselect can be accepted. If it does not fulfill the criteria it should throw an exception. Any help will be much appreciated

  • Where are using Multiselect picklist ?? If i understand correctly You have a lookup field and use want to filter record based on version field available on object. If this is the case you can Filter records of lookup fields by defining Lookup Filters. You can Refere Salesforce Document to apply lookup Filters. Jul 25, 2015 at 2:10
  • I cannot use look up filters here since the version field on object b is a multiselect picklist and you cannot use multi select picklist in look up filters
    – WKH123
    Jul 25, 2015 at 3:48

1 Answer 1


Hi you can have trigger on Child object to check if value selected in Child picklist is present in parent object's MultiSelect Picklist or not.

Giving you example using Account as Parent and contact as child

Account has Multi_version__c field as multi Select, While Contact has Version__C as picklist

trigger TgrPreventVersionSelection on Contact (after Insert, before update) {

   // first find Accounts to get multi Select pickList values 
   Set<Id> AccIds = new set<Id>();
   For(Contact c : Trigger.new) 
        if(c.AccountId != null)

   // Thsis map will  have parent object Id( Account here) and values of multiSelectPicKlist in Set. 
   Map<Id, set<string>> mpAcWithMultiPickList = new map<Id, set<string>>();
   List<Account> AccList = new list<Account>(); 

   AccList =  [select id, name, Multi_version__c from Account where Id = :AccIds];

  // once We have Accounts, we'll populate a map having Account ID and set of string present in multi Select piclist

   For(Account acc : Acclist)
     if(acc.Multi_version__c != null)
          list<String> slist = acc.Multi_version__c.split(';');
          set<String> versionStringSet = new set<string>(slist);
           mpAcWithMultiPickList.put(acc.id, versionStringSet); //converting list to set
        }// end of If condition
    }// for loop

   // Once we've map of Account and Set, we can ran check to see value selected in child is present in parent's multiselect(set of string) or not
    For(contact c : trigger.new) 
        if(c.AccountId != null)
            Set<string> SettoCompare =mpAcWithMultiPickList.get(c.AccountId);

                c.addError('Version doesn\'t Exist in Parent');


You must log in to answer this question.

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