You need to sign in to do that
Don't have an account?
Staci
Multipicklist in Where Clause
I have the following code. Business_Unit_new__c in the User object is the multipicklist.
I want to pull records from the License Numbers object where the Business Unit (picklist) from the License record is equal to the Business Unit of the current user (multipicklist). The users may have more than 1 Business Unit assigned to them.
I've tried WHERE Business_Unit__c INCLUDES (:currentuser.Business_Unit_new__c) and it errors saying includes can only be used with a multipick list
If I try
currentuser.Business_Unit_new__c INCLUDES (:Business_Unit__c) it errors saying it doesn't understand the relationship with currentuser.
How do I fix this?(this is not the complete code, jus tthe snipit that i need the query in)
I want to pull records from the License Numbers object where the Business Unit (picklist) from the License record is equal to the Business Unit of the current user (multipicklist). The users may have more than 1 Business Unit assigned to them.
I've tried WHERE Business_Unit__c INCLUDES (:currentuser.Business_Unit_new__c) and it errors saying includes can only be used with a multipick list
If I try
currentuser.Business_Unit_new__c INCLUDES (:Business_Unit__c) it errors saying it doesn't understand the relationship with currentuser.
How do I fix this?(this is not the complete code, jus tthe snipit that i need the query in)
public with sharing class LicenseList { private final License_Numbers__c ln; public user currentuser{get;set;} public id tobeEdited{get;set;} public decimal aTotal{get;set;} public decimal tTotal{get;set;} public List<AccountWrapper> wrappers{get;set;} private Integer nextIdent=0; public LicenseList(ApexPages.StandardSetController controller) { currentuser=new User(); currentuser=[Select Id, Business_Unit_new__c from User where Id=:userinfo.getuserId()]; this.ln = (License_Numbers__c)controller.getRecord(); wrappers=new List<AccountWrapper>(); for(Integer idx=0; idx<1; idx++) { wrappers.add(new AccountWrapper(nextIdent++)); } } //------------------------------------------------------------------------------------ public List<License_Numbers__c> lntypes16 = new List<License_Numbers__c>(); public List <License_Numbers__c> getLicenseList(){ lntypes16 = [select id, Name, X2016_Cost__c, Business_Unit__c, X2016_Starting_Amount__c, X2016_Subtotal__c, BMS_Code__c, License_Type__c, Monthly_Unit_Price__c, Running_License_Total__c, Org__c FROM License_Numbers__c where Business_Unit__c =:currentuser.Business_Unit_new__c AND License_Year__c = '2016' ORDER BY Order_Number__c, License_Type__c]; return lntypes16; }
I would usually deal with munltipicklist as follows. Note my addition to your code is first two lines and then using "IN" in the where clause.
Hope this helps.
Regards,
Mann.
I tried that and it complained about the ( after split so I changed it to
and it now complains about the ) after multiSelectValues.addAll(currentuser.Business_Unit_new__c);
Could you run the following code and paste the debug log:
Regards/
While I was waiting for you reply, I noticed something in your code:
why are you using Set<User>, as in here:
While the code that I wrote uses Set<String>, as in here:
Change that and it should get you rolling! !!
Cheers!
Mann
Hi Stacy, did it work ?multiSelectValues.addAll(currentuser.Business_Unit__c.split(';'));