You need to sign in to do that
Don't have an account?
sindhu@demo.com
Trigger on Activities in "Account" Object
Hi Everyone,
I have a custom field in "Account" Object(Remaining Meetings).
I need a trigger to roll up on Activities related to the Account object.
All the openactivities(Count) of type "Meeting" should be counted and displayed "remaining Meetings" field.
I have written a trigger on Tasks to count the no of open activities when a task is created and assigning the count value to the field in Account but the value is not updated.
Can anyone help me with this??
trigger UpdateAccount on Task (before insert)
{
for(Task t : Trigger.new)
{
Account acc =[SELECT id,Annual_On_Site_Meetings__c,Actual_Meetings_Year_to_Date__c,(SELECT Status,WhatId from OpenActivities Where ActivityType Like 'Meeting') FROM Account where id=:t.WhatId];
integer count = 0;
for(OpenActivity oa:acc.OpenActivities)
{
count++;
}
System.Debug('-------Count'+count);
acc.Annual_On_Site_Meetings__c=count;
}
}
You have to also say update acc; in the last line.
Hope this helps.