You need to sign in to do that
Don't have an account?
After Update Trigger on Account is not Working
I have a problem with Account trigger afterupdate event. Below are the problem details.
Expectation is: Whenever I update a Status column in Account, there is a method in AfterInsertUpdate in trigger which updates the status of custom objects related to Account(child objects)
Problem is : Whenever I update the Status column in Account, trigger fires and executes upto BeforeUpdate event and executes all the methods which are being called in Beforeupdate event. But after this I see in Debug log that some validation fires and after that again BeforeUpdate event starts and I see that oldmap no longer hold the status to which I updated the Account. i.e. oldmap and new values are same, which results in my condition in IF statement not meeting and hence update is not happening.
Actions Taken:
1. I commented the all the methods step by step being called in Before update and checked the logs but no luck.
2. I Inactivated all update workflows related to Account and checked but no luck again
Thanks in Advance for your help.
Trigger:
trigger IS_AccountTrigger on Account (after insert, after update, before insert, before update, before delete, after delete) {
system.debug('reached insisde trigger');
ISecG_Trigger_Settings__c objTriggerSetting = ISecG_Trigger_Settings__c.getInstance();
if(objTriggerSetting.Enable_Account_Trigger__c) {
if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate)) {
system.debug('reached inside after trigger');
IS_AccountTriggerHandler.afterInsertUpdate(); \\MY METHOD IS BEING CALLED FROM HERE
if(trigger.isInsert){
<CustomClass.CustomMethod>(Trigger.new,Trigger.oldmap);
}
}
if(Trigger.isBefore && (Trigger.isInsert || Trigger.isUpdate)) {
system.debug('reached insisde before trigger@@@@@');
IS_AccountTriggerHandler.beforeInsertUpdate();
}
if(trigger.isInsert && trigger.isBefore) {
IS_AccountTriggerHandler.beforeInsert();
}
if(trigger.isBefore && trigger.isUpdate) {
IS_AccountTriggerHandler.beforeUpdate();
}
if(Trigger.isBefore && Trigger.isDelete) {
IS_AccountTriggerHandler.beforeDelete();
<CustomClass.CustomMethod>(Trigger.old);
}
if(Trigger.isAfter && Trigger.isDelete) {
IS_AccountTriggerHandler.afterDelete(Trigger.old);
}
}
}
Expectation is: Whenever I update a Status column in Account, there is a method in AfterInsertUpdate in trigger which updates the status of custom objects related to Account(child objects)
Problem is : Whenever I update the Status column in Account, trigger fires and executes upto BeforeUpdate event and executes all the methods which are being called in Beforeupdate event. But after this I see in Debug log that some validation fires and after that again BeforeUpdate event starts and I see that oldmap no longer hold the status to which I updated the Account. i.e. oldmap and new values are same, which results in my condition in IF statement not meeting and hence update is not happening.
Actions Taken:
1. I commented the all the methods step by step being called in Before update and checked the logs but no luck.
2. I Inactivated all update workflows related to Account and checked but no luck again
Thanks in Advance for your help.
Trigger:
trigger IS_AccountTrigger on Account (after insert, after update, before insert, before update, before delete, after delete) {
system.debug('reached insisde trigger');
ISecG_Trigger_Settings__c objTriggerSetting = ISecG_Trigger_Settings__c.getInstance();
if(objTriggerSetting.Enable_Account_Trigger__c) {
if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate)) {
system.debug('reached inside after trigger');
IS_AccountTriggerHandler.afterInsertUpdate(); \\MY METHOD IS BEING CALLED FROM HERE
if(trigger.isInsert){
<CustomClass.CustomMethod>(Trigger.new,Trigger.oldmap);
}
}
if(Trigger.isBefore && (Trigger.isInsert || Trigger.isUpdate)) {
system.debug('reached insisde before trigger@@@@@');
IS_AccountTriggerHandler.beforeInsertUpdate();
}
if(trigger.isInsert && trigger.isBefore) {
IS_AccountTriggerHandler.beforeInsert();
}
if(trigger.isBefore && trigger.isUpdate) {
IS_AccountTriggerHandler.beforeUpdate();
}
if(Trigger.isBefore && Trigger.isDelete) {
IS_AccountTriggerHandler.beforeDelete();
<CustomClass.CustomMethod>(Trigger.old);
}
if(Trigger.isAfter && Trigger.isDelete) {
IS_AccountTriggerHandler.afterDelete(Trigger.old);
}
}
}
Thanks for your response on this. I checked the every validation rule and I see its passed. Below is the extract from debug log. ( i have removed some parts of validation rule log only which holds the client data).
Below log start from the end of Before update trigger event and ends with the start of the Before update again as stated before.
The oldmap holds the Old value of status correct untill actual update i.e. it holds the old value in all the before trigger context.
For ex; oldmap = {Status = 'Registered'}
newmap = {Status = 'Inactive'}
This is correct untill the actual update happens. But after Update old and new values looks like below.
oldmap = {Status = 'Inactive'}
newmap = {Status = 'Inactive'}
I have my logic in the after update which compares these 2 values and then does the job. but since old and new is same its not doing my job.
Even workflows are disabled, even then I noticed this behaviour.
None of them are updating status. And process builders criteria is not matching with this case.
@Nalinaki
Did you ever solve your issue? I'm having the same problem.