You need to sign in to do that
Don't have an account?
Querying a Multi Select Picklist Using Includes
Seen the postings related to this but cant find this use case. Writing a class with an If...Statement to check if a String variable "DayOfWeek" is present in a multi select picklist. I'm getting an error right after the variable 'calmonth' stating it wants a right parentheses.
Ex: DayOfWeek = 'Monday'
Multi Select Picklist = 'Monday';'Wednesday';'Friday'
Return = True since Monday is in list
Code:
String calday = c.ONE__DayofWeek__c;
String testing = [select ONE__Scheduled_Days__c from ONE__Schedule_Development__c where Id = :s].ONE__Scheduled_Days__c;**
**I tried putting this directly in If...Statement and using it as a variable
Problem Line In Code
If (calday includes (:testing)){....
Thanks,
Darrell
Includes is only for a query. In regular code, you need something like this:
Or, if you're sure nobody is going to mess with your picklist values, and you know that Monday won't appear elsewhere in the list (e.g. Monday Afternoon, Monday Morning), then you can use the more direct indexOf:
All Answers
Includes is only for a query. In regular code, you need something like this:
Or, if you're sure nobody is going to mess with your picklist values, and you know that Monday won't appear elsewhere in the list (e.g. Monday Afternoon, Monday Morning), then you can use the more direct indexOf:
**bleep**! Let me toil for a few hours yesterday on this!! I used the .contains method which worked right away!
Darrell