+ Start a Discussion

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


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


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