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
Paul80304Paul80304 

How can we find Opportunities that might be Related To a Task??

Hi,

I have this Apex trigger and supporting class that fires upon a Task update.  It basically looks at some of the fields and populates with default values if the fields haven't been defined (Subject, Status).  The trigger also resets the Due Date (ActivityDate) two weeks into the future to manage follow-ups with our customers (so our users don't always have to reset the date every time they want to roll the Task forward).   This is all working well.

PROBLEM: What I would really like to figure out now is how I can query the Task object to discover if there is an Opportunity out there that should be Related To the Task (when the Related To field is undefined).  I've been reading about the "WhatID" field on the Task object, but I can’t figure out how to query this field and set it if there is indeed an open Opportunity in the Task's parent Account object.  Would you happen to have an example, or any advice on how this could be accomplished?

Thanks for any help someone might be able to provide.

Kind regards

Paul


Message Edited by Paul80304 on 03-04-2008 03:18 PM