You need to sign in to do that
Don't have an account?
Sfdc@Smitha
Find the error in the trigger
Hi
Will the following trigger work ?can anybody will help me?
trigger tgrCounter on Mileage__c (after insert, after update) {
List MilToupdate = new List();
for(Mileage__c Mlg : Trigger.new){
Mlg.Counter__c = Mlg.Counter__c+1;
MilToupdate.add(Mlg);
}
update MilToupdate;
}
write the second line like this
List<Mileage__c> MilToupdate = new List<Mileage__c>();
All Answers
write the second line like this
List<Mileage__c> MilToupdate = new List<Mileage__c>();
not exactly sure what you are trying to do but it appears you're just trying to add one to that counter field every time a mileage record is inserted or updated
use this for that
trigger tgrCounter on Mileage__c (before insert, before update)
{
for(Mileage__c m: Trigger.new)
{
m.Counter__c = m.Counter__c+1;
}
}
You are trying to update a record in an after-trigger on this record. This should be done in a before-trigger.
Hope this helps,
Thanku for reply
please mark this resolved if the trigger above works. if not tell us why it won't meet your needs