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
Ross MuellerRoss Mueller 

Cross Object Trigger Update

Hello All!

I am trying to find a way when a task is marked as "complete", that the lead status is automatically updated to "L3 - In Dialogue". Any ideas??


Thanks!  
Kevin CrossKevin Cross
Good day, Ross! 

If the Task relates to a Lead, you should have a value in the WhoId column.  If you are using TaskWhoRelations, you may have TaskWhoIds.  In either case, you can find the Lead through the related WhoId and update its Status field appropriately.  Are you comfortable with Triggers?

Kevin
Ross MuellerRoss Mueller
Hey Kevin!

Thanks for getting back. 

I know some about Triggers, however still learning. Is there anything you would recommend?

Thanks!

 
Kevin CrossKevin Cross
Use an after insert, after update trigger and loop through each Task in Trigger.New.  In your IF condition, you can check for Status == "Completed" as well as WhoId != null and Who.Type == 'Lead'.  If all three conditions are met, add Lead defined by WhoId to List or Set that you later use to update Leads in bulk.  This way, you can handle multiple Tasks completed at same time as well as imported/created tasks with status already set to complete.
Bharat.SharmaBharat.Sharma
Hey Kevin, 
It looks like you are expert in triggers.
i have same problm but its Lead and event 
can you please help me.??
please click the below link to view full problm.

https://developer.salesforce.com/forums/ForumsMain?id=9060G000000XbUOQA0

Thanks And Regards 
Bharat Sharma