0

I am writing a trigger on Task. When a new task is created, I am using the who.id (in my case mostly lead) and converting lead in to Account, contact and opp. Duing this process I am reading subject line (standard subject pattern) of the task to use the fields in the contact creation. example subject line: [email protected].

Note : ' - ' is the delimiter.

I am using as below: if(task.Subject.indexOf('NewTask-') > -1)

Now, I have a similar requirement to read the standard pattern (company-firstname-lastname-phoneno) etc from the decription(body/comments) field of the task.

If anybody has any thoughts please share.

1 Answer 1

0

I tried below and I got what I was looking for. Posting it here in case if anybody in future comes across this.

Statements:

string test = tk.Description;
 system.debug('The description of the task is'+test);
 List descFields = test.split('-', 4); // This statement does the trick
 system.debug('The new body fields are: '+descFields[0]);
system.debug('The new body fields are: '+descFields[1]);
system.debug('The new body fields are: '+descFields[2]);
system.debug('The new body fields are: '+descFields[3]);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .