+ Start a Discussion

Trigger works as per debug log but does not update field value



This is kindof confusing. I have created a trigger on the Contact object which works on Before Insert and Before Update.


One of the snippets of the trigger is as follows:


System.Debug('trigger.isInsert section is fired');
System.Debug('atm.UserId: ' + atm.UserId);
System.Debug('c.ASD__c before'+c.ASD__c);
c.ASD__c = atm.UserId;
System.Debug('c.ASD__c after'+c.ASD__c);


The problem is that when the SAVE button is clicked, the ASD__c field still doesnt show the new user value (ASD__c is a User).


Upon checking the debug log, here is what I see:


16:15:51.142 (142136000)|USER_DEBUG|[49]|DEBUG|c.ASD__c beforenull
16:15:51.142 (142265000)|USER_DEBUG|[51]|DEBUG|c.ASD__c after005E0000000KojDIAS

As you can see, both the before and after values in the debug statement are different which implies that the field ASD__c actually got set. However, when SAVE is clicked, it doesnt show.

Kind of super confusing. Any clue, idea, suggestion?



Is there any other place (either in this trigger or anywhere else like a WF or another triggerA) where this field is again reset to null.

Satish Kumar