0

In my controller I have a variable called category which is of the following format: "category1;category2;category3"

I need a SOQL statement which pulls all case note records that have one of the listed category in my category variable. Each case note can only have a single category (category__c).

So for example my casenote variable might be "housing;financial;health". I'd want to pull all casenotes where category__c is housing or financial or health. How might I go about this?

Here's what I have so far:

casenotelist = [Select ID, Date_of_Service__c, Case_Note__c,Category__c, Case_Number__c, Entered_By_User__r.Full_Name__c,
                        Case_Member__c
                       from RIS_Case_Note__c 
                       Where Case_Number__c =: controller.getId() AND
                        Date_of_Service__c >=: startdate AND
                        Date_of_Service__c <=: enddate AND
                        category__c ???? :Category //need help on this line
                       ORDER BY Date_of_Service__c  ASC];
2
  • 5
    List<String> categories = String.split(Category, ';'); // WHERE category__c in :categories
    – kurunve
    Commented Jan 17, 2018 at 16:54
  • 1
    Did you try with 'includes' ?
    – Ysr Shk
    Commented Jan 17, 2018 at 16:54

1 Answer 1

2

Thanks to #kurunve for getting me started. This worked:

 categories = category.split(';'); 
        casenotelist = [Select ID, Date_of_Service__c, Case_Note__c,Category__c, Case_Number__c, Entered_By_User__r.Full_Name__c,
                    Case_Member__c
                   from RIS_Case_Note__c 
                   Where Case_Number__c =: controller.getId() AND
                    Date_of_Service__c >=: startdate AND
                    Date_of_Service__c <=: enddate AND
                    category__c in :categories
                    ORDER BY Date_of_Service__c  ASC];
0

You must log in to answer this question.

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