+ Start a Discussion
ZurMilesZurMiles 

Trigger on Task Object

Hello all, 

 

I have a question involving the Task object, Lead object, a Workflow and 2 custom fields, one on the Lead page and another on one Task page layout.

 

The logic is that when a user change the value of a field (Picking list) in the Lead page layout, a workflow will create a task for the Lead Owner.

This is done easily with a Workflow. 

 

Here is what I want to do now and I haven't been able to accomplish yet. 

I want to change the value of a custom field (‘C’) that it is on that Task generated by the workflow. 

 

Explanation: 

 

There is a custom field on the Leads object page layout. This field is a picking list data type.

 

We have a number of people that will be working with our leads and they will make a number of changes on these leads.

One of the updates will need to be done on a field, lest call it, field ‘A’.

 

Depending on the values selected on the ‘A’ field a workflow will be triggered. This workflow will be responsible for the creation of a new Task. This Task will be send to the Lead Owner.

 

On that same Lead page layout there is another field, field ‘B’. The intention is to put the ‘B’ field value into a custom field in the new Task, field ‘C’. The new task is created by the workflow.

 

What I’m trying to do is to build a Trigger on the Task object (after insert), that will add the value of the Lead ‘B’ field into the ‘C’ field on the new task that will be generated depending the value on the field ‘A’, by the workflow.

How can I do this?

How can I build a trigger that will add the value of that specify Lead field (‘B’) value in to the new task field ‘A’?

 

I’m busy with APEX but I’m not a guru L … any help will be great!

 

Thanks in advance.

 

 

Jeff MayJeff May

If you're using triggers, you'll want to check the Task.WhoID to get the ID of the Lead, then query for "Lead.FieldB where ID = theWhoId. The rest is a simple field replace.

 

Success,

 

JeffM