function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shuhbam SinhaShuhbam Sinha 

How to use split for comma separated values to update fields in apex

Hello ,
I have one requirement where in I am capturing three fields value on a text field with a comma separated values . Three values are Id of a record, phone no and email of the record. Now i need to update three different fields on an other object with the text field(where I am storing Id, phone and email ). If that text filed contains an id then update the look up field , if the text field contains phone then update the phone field and same goes for email field. 

Could anyone please help me how to use split functionality here to update the three differnet fields from one text field which contains all the values in Apex.
Thank you in advance

Best Answer chosen by Shuhbam Sinha
CharuDuttCharuDutt
Hii Shubham
Try Below Code Example
String allFields[]=  Data.split(',');
       Account acc=new Account();
        acc.name=allFields[0];
   acc.Company=allFields[1];
   acc.Email=allFields[2];
insert acc;
Please Mark It As Best Answer If It Helps
Thank you!