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
Andréa de FariaAndréa de Faria 

Copy field from Task to Event with same Contact

Hello,

In our company, the Task object have a field called "Meeting Notes", which is the standard "Description" Text field of the Task object, but with the label "Meeting Notes".

Please, how can I copy the value from this field in the most recent Taks created and paste it in a custom Event field called "Pre Meetin Notes".

This Event will also be the latest one created.

The Task and the Event will have the same Contact in common.

I tried with Process Builder and formula fields, but none of these worked.

Appreciate your help.
Best Answer chosen by Andréa de Faria
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Andrea,

I have used a lightning flow to achieve it. We are using record trigger flow and only in create scenerio. When ever a new event is created it will copy the description field from the latest task which is associted to the contact.

Record Trigger flow starting condition:

User-added imageget associated latest event:

User-added image
Update the task description:
User-added image
Entire Flow:

User-added image

Let me know if you need any help on it.

If this solution helps, Please mark it as best answer.

Thanks,
 

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi Andrea,

What should be the behaviour if the contact has multiple events. On which Event record I should populate the field. Is that okay to use the APEX in the above requirement or you want it using some lightning flows.

Thanks,
 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Andrea,

I have used a lightning flow to achieve it. We are using record trigger flow and only in create scenerio. When ever a new event is created it will copy the description field from the latest task which is associted to the contact.

Record Trigger flow starting condition:

User-added imageget associated latest event:

User-added image
Update the task description:
User-added image
Entire Flow:

User-added image

Let me know if you need any help on it.

If this solution helps, Please mark it as best answer.

Thanks,
 
This was selected as the best answer
Suraj Tripathi 47Suraj Tripathi 47
Hi Andrea.

it will work through the triggers:

Example:
trigger tasktrigger on Task (after insert) {    
if(trigger.Isafter && trigger.ISinsert){     
CopyField.copytaskfield(trigger.new);     
}  
}
 
Apex handler:
public class CopyField {     
public static void copytaskfield(List<Task> tasklist){        
List<Event> eventlist = new List<Event>();         
for(task obj:tasklist){             
Event eventobj = new Event();             
eventobj.WhoId= obj.WhoId;             
eventobj.Description = obj.Description;             
eventobj.ActivityDate = date.today();             
eventobj.DurationInMinutes=20;            
eventobj.ActivityDateTime = date.today();             
eventlist.add(eventobj);                     
}         
insert eventlist;     
}  
}
 
Or you can use flow for this.
hope this will help you.

Thanks.
Andréa de FariaAndréa de Faria
Thank you all !

@Sai Praveen, your flow worked perfectly!!!!!!

@Suraj Tripathi 47, I'm not so familiar with triggers, but thank you for your detailed answer!