0
String Accounttype = 'College/University;State/Local Government';

list<string> lstacctype = Accounttype.split(';'); 

    String slist = '';

   for (String s1: lstacctype) {

   slist += '\'' + s1 + '\',';

   }

   slist = slist.substring (0,slist.length() -1);

[select Id,Country__c FROM User_Mapping_Location__c WHERE State_Province__c =null and City__c = null and User__c =: userId and Sales_Rep_Configuration__r.Account_type__C includes (:slist )]

Please help where am i doing wrong,even the debug statement of the 'slist' is returning values in Correct format

15:54:47:059 USER_DEBUG [16]|DEBUG|'College/University','State/Local Government'

2
  • are you looking for partial matches with those strings ? if not, after you split the values into an Array, you can simply use IN clause and pass the array instead of using INCLUDES.. – Vamsi Krishna Gosu Jul 10 '17 at 23:32
  • i changed it to [select Id,Country__c FROM User_Mapping_Location__c WHERE State_Province__c =null and City__c = null and User__c =: userId and Sales_Rep_Configuration__r.Account_type__C in :lstacctype ] but still no results,results are still 0,so i checked again passing values manually its working fine,SO donno why its not returning results – Harish Vennam Jul 11 '17 at 0:16
0

Your includes parameter need to be semicolon separated. see here below will give you the result. What you are getting in the string you are preparing it needs to be like below

String Accounttype = '\'College/University\',\'State/Local Government\'';
[select Id,Country__c FROM User_Mapping_Location__c WHERE State_Province__c =null and City__c = null and User__c =: userId and Sales_Rep_Configuration__r.Account_type__C includes :Accounttype ];
2
  • no @avijit still the same result – Harish Vennam Jul 11 '17 at 14:56
  • When i see the debug log its giving the results in the format SOQL query expects 'A' , 'B' for the Variable ,for some its still not returning any results – Harish Vennam Jul 11 '17 at 18:07

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.