PartOfTheOhana
PartOfTheOhana

Reputation: 685

updating a field on contact whenever a new event is created?

Here is the problem I'm trying to solve:

When a new TASK/EVENT is created, if the user is a certain profile - we want to update a field on CONTACT with the day the T/E was created.

I tried doing a workflow rule and field update- but I couldn't get it to work... I think since this is a Standard -Standard object relationship via lookup, it might have a problem doing a field update. Any other ideas?? I'd prefer to use the platform for this one...

HALP!

Thanks

Upvotes: 1

Views: 924

Answers (1)

Jay Eckles
Jay Eckles

Reputation: 103

We have done exactly what you are talking about via an Apex trigger. Something like this...

//I'm sure this doesn't compile, but it gives you the idea
trigger taskTrigger on Task( after insert, after update ){
   Task t = trigger.new ;
   Contact contact = [Select Id from Contact where Id = :t.whoId] ;
   contact.yourfield = t.AcitivityDate ;
   update contact ;
}

Upvotes: 3

Related Questions