You need to sign in to do that
Don't have an account?

Creating a list from a text field
Hello developers,
I have a text field test__c on an object TestObject__c. This filed has values seperated by commas (a,b,c,d). In my apex class, I would like to pass these values into a list TestList. Can someone please provide me with the correct syntax?
Thanks!
I have a text field test__c on an object TestObject__c. This filed has values seperated by commas (a,b,c,d). In my apex class, I would like to pass these values into a list TestList. Can someone please provide me with the correct syntax?
Thanks!
Also can be shortened to:
All Answers
You can use split method
TestObject__c testObj{get;set;}
List<String> TestList = new List<String>();
if(testObj.test__c != null && !''.equals(testObj.test__c)){
TestList = testObj.test__c.split(',');
}
Regards,
Bhanu Mahesh
Also can be shortened to:
Hope this helps!!
Thank you
BLearn
Error: Compile Error: Method does not exist or incorrect signature: [Schema.SObjectField].split(String)