You need to sign in to do that
Don't have an account?
podgercor1.3917890117104897E12
event trigger problem
I'm trying to write a trigger that will fire when an event is marked as Completed (on custom Status field). When this happens I want to update the related Account with a timestamp of when this happened
i.e Event marked completed - Account field Timestamp is set to today
i've tried writing the code for it but have not been able to get beyond the below, any ideas/tips would be appreciated - thanks
code -------------------------
trigger Timestamper on Event (after insert, after update)
{
List <ID> AccId = New List <ID>();
for (Event e: trigger.new)
{
if (e.Meeting_Status__c == 'Completed' && e.WhatId !=null)
{
AccId.add(e.WhatId);
}
}
List <Account> accList = [SELECT id, Timestamp__c FROM Account WHERE id in:AccId];
{
accList.Timestamp__c = System.today();
}
update accList;
}
i think i am close here but getting an "initial term of field expression must be a concrete SObject" error here??
i.e Event marked completed - Account field Timestamp is set to today
i've tried writing the code for it but have not been able to get beyond the below, any ideas/tips would be appreciated - thanks
code -------------------------
trigger Timestamper on Event (after insert, after update)
{
List <ID> AccId = New List <ID>();
for (Event e: trigger.new)
{
if (e.Meeting_Status__c == 'Completed' && e.WhatId !=null)
{
AccId.add(e.WhatId);
}
}
List <Account> accList = [SELECT id, Timestamp__c FROM Account WHERE id in:AccId];
{
accList.Timestamp__c = System.today();
}
update accList;
}
i think i am close here but getting an "initial term of field expression must be a concrete SObject" error here??
trigger Timestamper on Event (after insert, after update)
{
List <ID> AccId = New List <ID>();
for (Event e: trigger.new)
{
if (e.Meeting_Status__c == 'Completed' && e.WhatId !=null)
{
AccId.add(e.WhatId);
}
}
List <Account> accList = [SELECT id, Timestamp__c FROM Account WHERE id in:AccId];
for(Account acnt : accList)
{
acnt.Timestamp__c = System.today();
}
update accList;
}
All Answers
trigger Timestamper on Event (after insert, after update)
{
List <ID> AccId = New List <ID>();
for (Event e: trigger.new)
{
if (e.Meeting_Status__c == 'Completed' && e.WhatId !=null)
{
AccId.add(e.WhatId);
}
}
List <Account> accList = [SELECT id, Timestamp__c FROM Account WHERE id in:AccId];
for(Account acnt : accList)
{
acnt.Timestamp__c = System.today();
}
update accList;
}
Thanks,
Sai