Find your content:

Search form

You are here

SOQL for Multi-select picklist in where clause having a variable

 
Share

How about this below I called this class method from a trigger providing a string value to it, which is same as User's service segment field ( a multi select picklist). but I am getting an error in this line:Service_Segment__c includes leadServiceSegment . The error is expecting a left parentheses, found 'leadServiceSegment'. How to go about it.

public void leadOwners(string leadServiceSegment){
    list<user> bdeOwners = [Select ID, Name, Related_Team__c, service_segment__c,ComplianceServices__c, Registration__c, IPR__c, ISO__c 
                                            from User 
                                                where 
                                            (ComplianceServices__c = true
                                              OR
                                             Registration__c = true
                                             OR
                                             IPR__c = true
                                             OR
                                             ISO__c = true)
                                            AND
                                            **Service_Segment__c includes leadServiceSegment**
                                            AND 
                                            isActive = true 
                                            AND 
                                            On_Leave__c = false 
                                            ORDER BY name desc];

}


Attribution to: Rohit

Possible Suggestion/Solution #1

I think you just need to but a ':' before the variable reference and put brackets around it.

ie using your code

...
OR
ISO__c = true)
AND
  Service_Segment__c includes (:leadServiceSegment)
AND 
isActive = true 
...

Attribution to: Stuart McVicar
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/31311

My Block Status

My Block Content