You need to sign in to do that
Don't have an account?
CarlB
Duplicate record created, but trigger only called once
Hello.
I have a very odd situation.
I have some code that makes a web service call and then inserts a record based on the result of this call. The insert causes an after-insert trigger to run that updates a running-total amount field in a related record (it isn't a master-detail relationship, so can't use a rollup field).
This code has been installed as a managed package on various customer's orgs and works ok.
However, on one customer's org something strange happened. The user invoked the functionality, but two identical records were created (down to having the same created timestamp). But, the trigger appears to have only run once, because the total field in the related record only reflects a single update.
This leaves me with two possibilities:
1) Everything worked as expected, but the trigger ran twice in parallel, meaning that one update overwrote the other update
2) Salesforce has a bug that causes duplicate records to be created without any other effect.
Any thoughts?
Regards,
Carl
I have a very odd situation.
I have some code that makes a web service call and then inserts a record based on the result of this call. The insert causes an after-insert trigger to run that updates a running-total amount field in a related record (it isn't a master-detail relationship, so can't use a rollup field).
This code has been installed as a managed package on various customer's orgs and works ok.
However, on one customer's org something strange happened. The user invoked the functionality, but two identical records were created (down to having the same created timestamp). But, the trigger appears to have only run once, because the total field in the related record only reflects a single update.
This leaves me with two possibilities:
1) Everything worked as expected, but the trigger ran twice in parallel, meaning that one update overwrote the other update
2) Salesforce has a bug that causes duplicate records to be created without any other effect.
Any thoughts?
Regards,
Carl
refer https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm
The trigger is:
The VF controller extension page action is:
So, the user clicked a button that ran the above code, but two A__c records were created (identical creation timestamps). The trigger appears to have only processed only one of the A__c records because the B__c record linked to the records ended up with a Number__c of 1 and a Total__c of Amount__c (rather than Amount__c * 2)
There are no workflows defined for either A__c or B__c.
Regards,
Carl
Something that occured to me is - does Salesforce prevent double form submission on its standard buttons? That is to say, if I click a button on a standard Salesforce page, does Salesforce do anything to prevent me very quickly clicking the same button?
Similarly, if two records are inserted at the same time, is it possible for the same trigger to be running twice at the same time? If so, in the above example, should I be doing an "FOR UPDATE" select on object B__c?
Regards,
Carl