String Split method in Apex in Salesforce March 17, 2020June 9, 2022InfallibleTechie Admin Sample Code: String str = ‘abc-xyz-123’;List < String > strList = str.split( ‘-‘ );System.debug( ‘List String is ‘ + strList ); Output:
Hi, Hope you are doing well! How can i pass this. i have custom label which is having two email address and i need to pass this in toaddress. But i am getting an error like below Initial expression is of incorrect type, expected: String but was: List Code starts from: string toaddressList =label.ADM_Rm_OtherAdddress; String[] toaddresssplit =toaddressList.split(','); String[]toAddresses = new String[] {toaddresssplit}; Log in to Reply
Hi,
Hope you are doing well!
How can i pass this. i have custom label which is having two email address and i need to pass this in toaddress. But i am getting an error like below
Initial expression is of incorrect type, expected: String but was: List
Code starts from:
string toaddressList =label.ADM_Rm_OtherAdddress;
String[] toaddresssplit =toaddressList.split(',');
String[]toAddresses = new String[] {toaddresssplit};
Use toAddresses = toAddresssplit; and let me know whether it works.