I have an iteration of DelegatedAccount (Standard SF object). When Im using obj.picklistValues.split(';').contains(value) its returning false. This is surprising as its a simple operation and should return true.

Here is the code

Class 1:

List<String> alignmentsMyAccountTab = new List<String>{'Account Owner','External','Manual'};

for (DelegatedAccount delAcc: emaAccountList ){
    if(delAcc.ECX_Alignment_Type__c == ECX_GlobalConstants.PRIMARY_ALIGNMENT){  // this works

         System.debug('split roles are'+ (delAcc.ECX_Roles__c).split(';'));  //1
         System.debug('dhdh'+(delAcc.ECX_Roles__c).split(';')[1]);          //2
         System.debug('bool valuex after match'+                           //3

// System.debug('bool valuey after match'+ (delAcc.ECX_Alignment_Type__c    //commented 4 
 == ECX_GlobalConstants.PRIMARY_ALIGNMENT) && delAcc.ECX_Roles__c != null
                 && (delAcc.ECX_Roles__c).split(';').contains(ECX_GlobalConstants.NON_INHERITED_ROLE));

    // below if condition not working
    if(alignmentsMyAccountTab.contains(delAcc.ECX_Alignment_Type__c) || (delAcc.ECX_Alignment_Type__c == ECX_GlobalConstants.PRIMARY_ALIGNMENT &&
((delAcc.ECX_Roles__c) != null && (delAcc.ECX_Roles__c).split(';').contains(ECX_GlobalConstants.NON_INHERITED_ROLE)))){

Class 2: (ECX_GlobalConstants)

public static final String INHERITED_ROLE = 'Inherited';
public static final String NON_INHERITED_ROLE = 'Non-Inherited';
public static final String PRIMARY_ALIGNMENT = 'Primary';                    

my delAcc.ECX_Roles__c contains the following in database - Inherited;Non-Inherited. The ECX_roles__c is a MultiPicklist

For the above code this is what I see in console

enter image description here

Also surprisingly if I uncomment the 4th System.debug in my code - deployment fails with message

Only Boolean Values can be applied with logical operators.

I thought String.split(';').contains(StringValue) will return a boolean. My if condition is also failing.

I am confused and unable to understand this behaviour

  • Please edit the question to include the declarations (if not the exact values) of your various constants. Typing issues may relate to the types for these values.
    – Phil W
    Commented Mar 30 at 7:53
  • edited the question to include the constants
    – Amax1
    Commented Mar 30 at 8:09
  • Check precedence in your commented out line 4. Use brackets if needed.
    – Phil W
    Commented Mar 30 at 9:20

1 Answer 1


Your constant is Non-Inherited (uppercase I), while the value in the multipicklist is Non-inherited (lowercase i), they are not the same string.
Only the equality operators (==) and WHERE clause in SOQL run a case-insensitive check against Strings.

Just chaging your constant to Non-inherited should solve the issue.
In similar cases you could also build a Set of lowercase (or uppercase) strings, then checking if it contains your lowercase (or uppercase) string, i.e.:

Set<String> lowercaseRoles = new Set<String>();
for (String ecxRole : delAcc.ECX_Roles__c.split(';')) {
if (lowercaseRoles.contains(ECX_GlobalConstants.NON_INHERITED_ROLE.toLowerCase()) {
    // something

You must log in to answer this question.

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