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
Functionality by apex codeFunctionality by apex code 

General Development

I would like to accomplish with an Appex Code OR Visual Force button that when I go to any Contact to create an activity (task -event- log a call) this new Activity "WILL BE RELATED TO" the Account they are associated to.
Can you help me to accomplish this? Salesforce Basic Support guide me to Developers website

Thank you,

 

Golan Jason Lewkowicz

212-431-3476 x202

pankaj.raijadepankaj.raijade

you can write triggers on event and task insert. 

 

check if it is against contact. if yes retirve accountid of the contact by query and update in event or task.

 

Regards,

Pankaj Raijade

 

mohimohi



trigger AutoCreateFollowUpTasks on Task (after insert) 
{
if(trigger.isinsert)
 {
 list<contact> ct=[select id,accountid,name from contact where id=:trigger.new[0].whoid];
 if(ct[0].accountid !=null)
 {
 task temptask=[select id ,whoid,subject from task where id=:trigger.new[0].id ];
 temptask.whatid=ct[0].accountid;
 update temptask;
 }
 }   
}