+ 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.