You need to sign in to do that
Don't have an account?
wedaft
Trigger to update a field in parent record once a task is created
I need to create a trigger that does the following:
Whenever a new task with a subject of "Email: CO1 Feedback" is created on a contact record, a field on that contact record called "CO1_followup_email_date__c" should be updated to match the date that the task was created.
The code that I used is below. I am not getting any error messages, but when I create the task with the proper subject line, the CO1 Follow-up email date is not updated. Any ideas?? Thanks for your help!
trigger Contactbirthdayupdate on Task (after insert) { List<Contact> ContactsToUpdate = new List<Contact>(); for (Task t: Trigger.new) { if (t.subject=='Email: CO1 Feedback') { Contact c = new Contact(Id=t.WhatId); c.CO1_Followup_email_date__c = t.ActivityDate; ContactsToUpdate.add(c); } } try { update ContactsToUpdate; } catch (system.Dmlexception e) { system.debug (e); } }
Its whoId not WhatId... update to..
Contact c = new Contact(Id=t.WhoId);
All Answers
Its whoId not WhatId... update to..
Contact c = new Contact(Id=t.WhoId);
Ah, yes that makes sense. Thanks!