You need to sign in to do that
Don't have an account?
APEX Code is not working!!!!
Hi All:
I am trying to assign multiple default values in String[] but its not working. Could you please help me out.
NOT WORKING BELOW CODE
==========================================================================
if (leadDivision.size()!=0) {
for(Integer k =0; k < leadDivision.size() ;k++)
{
userDivisionName=userDivisionName+'\''+leadDivision[k].Division__r.Name+'\'';
if(k<leadDivision.size()-1)
userDivisionName=userDivisionName+', ';
}
division=new String[]{userDivisionName};
}
WORKING BELOW CODE
==========================================================================
division=new String[] {'Corporate Office','Laboratory Equipment','Scientific Instruments'};
i tried a lot for all string manupulations but its not showing me as selected for not working code.
OK, I think I see the problem here.
This is not going to instantiate an array:
Not sure why you are going to the trouble of crafting a comma-delimited string when you could presumably just be doing this:
Does that work?
All Answers
gonna need more detail here.
Questions:
Hi Thanks for reply:
I am trying to build that string to show selected values multidropdown list. example: i have 10 divisions and i wanted to show 3 as PRE-selected in the dropdown.
If hardcode divison values then its working but when i build string with values then its not showing me as preselected in multilist
QUERY
divQryUser='Select u.User__c,u.Id, u.Division__r.Name,u.Division__r.Id From User_Division__c u where user__c= \''+UserInfo.getUserId()+'\'';
if(isDivisionActive){
divQryUser+= ' and u.Division__r.is_Live__c=true';
}
String divAdlUserQry=' order by u.Division__r.Name';
String divFinalUserQry=divQryUser+divAdlUserQry;
leadDivision =Database.query(divFinalUserQry);
Output for Divison String
('Corporate Office', 'Laboratory Equipment', 'Scientific Instruments')
I removed/added/escaped quotes for above string but its not showing me selected in the multilist.
but if i hardcode those values as below command then its shoing me as preselected.
division=new String[] {'Corporate Office','Laboratory Equipment','Scientific Instruments'};
OK, I think I see the problem here.
This is not going to instantiate an array:
Not sure why you are going to the trouble of crafting a comma-delimited string when you could presumably just be doing this:
Does that work?
OK, I think I see the problem here.
This is not going to instantiate an array:
Not sure why you are going to the trouble of crafting a comma-delimited string when you could presumably just be doing this:
Does that work?
Thank you so much