You need to sign in to do that
Don't have an account?
Cameron Bumstead
Copy an activity to a custom object
I am looking for a trigger that will relate an activity to a custom object. The custom object is "Vendor Product" and right now, there is a lookup field on the contact that relates the contact to the Vendor Product. Essentially, if the Vendor Product is not blank, I would like the activity to be related to the contact and the Vendor Product that the contact is related to. Could someone help me out with a trigger? I can clarify more if need be.
Thanks!
Thanks!
1) How is the activity record getting created and what is it related to?
2) is there something on the activity record that tells you that it needs to be related to the Contact.Vendor Product?
3) Do you know about WhoId and the WhatId on activity?
I think you would want a before insert, before update trigger on Task. IIRC - you can't do a trigger on activity.
Maybe something like this...
Of course - I'm not sure on syntax and field names. And ofcourse - you'd want to do more testing around the contactIds.add(t.whoid); line.
So, I think you put the before insert, before update trigger on task. Get a set of contact IDs from the triggered tasks. Then get those contacts and build a map that is key'd by the contact ID, and has the VendorProduct Id. Then loop through the triggered Tasks again, and update the what Id.