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
orikkerorikker 

Trigger on Tasks

Here is a problem:

 

We need to be able to populate a date field on Opportunity every time a new task of specific record type is created and related to opportunity (and ONLY). 

 

Solution: create a trigger on insert. Here is where I am stuck, how to check if a task that is being created, relates to opportunity and not other object? 

 

Thank you. 

Best Answer chosen by Admin (Salesforce Developers) 
gm_sfdc_powerdegm_sfdc_powerde

Check the first 3 characters of parent id field.  If it's 006, this is a task on opportunity

All Answers

gm_sfdc_powerdegm_sfdc_powerde

Check the first 3 characters of parent id field.  If it's 006, this is a task on opportunity

This was selected as the best answer
orikkerorikker

Awesome. Thanks :)