+ Start a Discussion
Shabbir ShaikShabbir Shaik 

Problem to get multiselect picklist values from soql to string

//oppcountry is List<String>

cnt= [select Id,Name,Opp_Country__c from Mat__c where Opp_Country__c<>''];

for(integer i=0;i<cnt.size();i++){
oppcountry= cnt[i].Opp_Country__c.split(';');
}

can anybody help me in this, I am unable assign country values to oppcountry.
Thanks in advance.
SaiGSaiG
Try using a string variable instead and then parsing through the string

String oppCountry = '';
List<String> opC;
List<Mat__c> mat = [select Id,Name,Opp_Country__c from Mat__c where Opp_Country__c<>''];
for(Mat__c m : mat){
    oppCountry = m.Opp_Country__c;
}

if(oppCountry.contains(';')){
      opC = oppCountry.split(';');
      for(Integer i=0;i<opC.size();i++){
          system.debug('Country: '+opC[i]);
       }        
}

Thanks,
Kishore

Shabbir ShaikShabbir Shaik
Hi Sai,

Thanks for your reply, I tried using this but its not working, The values are passing into string but not populating in List<String>.
SaiGSaiG
Did you select multiple countries for the multi picklist field? If you have selected only one country, the List<String> would be blank.