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

Apex Trigger Required - Custom Opportunity Field to Custom Task Field

Hi all,


I'm really struggling with Apex and Apex Triggers in particular, just doesn't make a lot of sense and hoping someone might be able to assist me, I want a simple formula/workflow but since I'm dealing with two separate objects Salesforce just won't play ball...


We have a custom opportunity field for 'Territory' and I want this to be shown on any new tasks, sounds so simple but it seems the only way to get this working is via an Apex Trigger and I'm not sure where to begin.


Can anyone suggest how I can get this working?




Jeff MayJeff May

The Task object has a "WhatId".  If the "WhatID" is an Opportunity (one easy way is to see if the ID begins with '006'), then your task trigger on insert or update can query for the Territory field on the Opp and set it's value to a custom Task field.