You need to sign in to do that
Don't have an account?
Starforce1
Trigger.New pulling Old Values in After Update Opportunity
I'm working with Triggers and I believe there is an unreported bug that I have found regarding Trigger.New and Trigger.Old. Here is the bug:
1. It's a Trigger on Opportunity after update. I even tested this with before update.
2. We are using Salesforce API (wsdl) to update the Opportunity from an external application.
3. When the Trigger fires, the objects Trigger.New and Trigger.Old (any field), holds the same exact values.
I expected that Trigger.New would hold the new values (the ones that will be updated in the database after the order of execution completes), while the Trigger.Old would hold the current/previous values. I made sure there are no workflows and other processes interfering with this particular field. I know I know, there are tons of resources showing how to compare the old and new values and I've tested them all to no avail.
The important thing to note: When a user updates the Opportunity in Salesforce, the Trigger works perfectly fine. The Trigger.New reflects the new values that will be updated, and the Trigger.Old reflects the old values. BUT when we are updating the Opportunity from an external application using the Salesforce API wsdl, the Trigger.Old and Trigger.New objects are exactly identical when the trigger fires. However, after the entire Order of Execution complets, the fields do indeed reflect the new values in the Salesforce interface.
Has anyone had this issue? Or can somebody test/help with any ideas/input?
Thanks a lot.
1. It's a Trigger on Opportunity after update. I even tested this with before update.
2. We are using Salesforce API (wsdl) to update the Opportunity from an external application.
3. When the Trigger fires, the objects Trigger.New and Trigger.Old (any field), holds the same exact values.
I expected that Trigger.New would hold the new values (the ones that will be updated in the database after the order of execution completes), while the Trigger.Old would hold the current/previous values. I made sure there are no workflows and other processes interfering with this particular field. I know I know, there are tons of resources showing how to compare the old and new values and I've tested them all to no avail.
The important thing to note: When a user updates the Opportunity in Salesforce, the Trigger works perfectly fine. The Trigger.New reflects the new values that will be updated, and the Trigger.Old reflects the old values. BUT when we are updating the Opportunity from an external application using the Salesforce API wsdl, the Trigger.Old and Trigger.New objects are exactly identical when the trigger fires. However, after the entire Order of Execution complets, the fields do indeed reflect the new values in the Salesforce interface.
Has anyone had this issue? Or can somebody test/help with any ideas/input?
Thanks a lot.
If you aren't using this method, the reason why your trigger works in SF is because in SF you can only edit one record at a time, so the lists always contain only 1 entry, no room for error there. However, when updating via the API, you could possibly be sending in more than 1 record, and therefore the list records ordering is not what you expect. If you don't want to post your trigger code, at least in your API, try only updating a single Opportunity record to see if you get the same behavior.
I truly hope this helps. Once you get a resolution, please comment back and mark a comment as 'Best Answer' (even if it isn't mine). This marks this thread as solved and helps the community. Thanks!
We narrowed down a lot of this issue, and it turns out that the Opportunity .update through the API Soap WSDL is NOT triggering the Apex Trigger (after or before update). So the main problem here is that the Apex Trigger simply isn't firing after the WSDL does the .update. Even though, in our VB.net code, I can run a SOQL on the Opportunity and see that clearly it updated the field after the .update.
Hope this helps.
Did you get this issue resolved? Sorry again, but I just noticed this - you are using an 'after update' trigger.... Are you getting the same results on 'before update'?
The REST API on the other hand works with our exact same process. Thus we are transitioning from SOAP WSDL to REST all together... Which is going to benefit us in the future as well.
Hi All,
I am also facing same issue
I have an application object i am updating some fields in to it then the after update trigger is firing but in the Trigger.New giving the old values rather than updated value , i dont why its happening
But the record is updated , isssue in trigger
Please give me a solution correct solution for this isssue
Thanks