You need to sign in to do that
Don't have an account?
r999
Trigger: After insert - to update a field instantly within the same object
Hi All,
I am trying to update a field in the same object after inserting, with the new data - But the outstanding__c field is not updating.
Please check my below trigger and give me any solution for this.
Thanks in advance,
trigger feedue on Payment__c (after insert) {
for(Payment__c p:Trigger.New)
{
Payment__c c=[select due__c from payment__c where id=:p.id];
Payment__c m=[select outstanding__c from payment__c where id=:p.id];
c.due__c=m.outstanding__c=c.due__c;
update m;
}
}
After Event triggers are used to update related information. You should not use an After Event trigger to update the records involved in the current transaction.
You dont need a trigger in your case... you can use workflow rule... or use trigger as shown below..
trigger feedue on Payment__c (before insert) {
for(Payment__c p:Trigger.New)
{
//Payment__c c=[select due__c from payment__c where id=:p.id];
//Payment__c m=[select outstanding__c from payment__c where id=:p.id];
p.outstanding__c=p.due__c;
//update m;
}
}