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
symantecAPsymantecAP 

Trigger on Account

Hi All 

 

I have a check box field on Account Object which becomes True When there is Activity History present.

I have to write a Trigger on Account which updates the checkbox field when there is Activity History.

 

Kindly help

symantecAPsymantecAP

Here it is

 

trigger activity on Account (before insert,before update) {
for (Account a: trigger.new){
if (a.lastactivitydate==null)
{
a.HasActivityHistory__c =true;
}

}

}

Navatar_DbSupNavatar_DbSup

Hi,


your trigger should be like this:


trigger activity on Account (before insert,before update)

{
                for (Account a: trigger.new)

                {
                                if (a.lastactivitydate!=null)
                                {
                                                a.AshishPackage__ActivityChk__c =true;
                                }

                }

}


My suggestion is that you should write a trigger on activity (task and event) instead of Account.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.