function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dmchengdmcheng 

Evidence of transaction rollback in debug log?

Today I ran into a situation where an apparent transaction rollback occurred, so my AfterInsert trigger did not create records as I expected.  It made me wonder if rollback is recorded in the debug log.  I searched the debug log for "rollback" but didn't find anything.  Is rollback recorded in some other way?  I have the standard settings on the debug log filters.  I looked at all the highest settings but didn't find any rollbacks apart from SAVEPOINT_ROLLBACK, which did not appear in my logs.

 

 

Here are the details:

I have an AfterInsert trigger on CampaignMember that creates Opportunity records.  A 3rd party application (Eventbrite Connector) creates CampaignMember records.  If the Eventbrite Connector throws an when creating a CampaignMember record -- i.e. trying to add a contact that is already a campaign member -- then my trigger does create Opp records for the other CampaignMembers in the batch, but then all Opps get rolled back with no warning or errors.

 

thanks

david

grigri9grigri9

SAVEPOINT_ROLLBACK will only show up in the logs when you use a savepoint in your code. When you have an unhandled exception during a commit to the database salesforce will just rollback any transactions that occured during that commit.

 

Are the campaign members that aren't throwing an exception being inserted succesfully?

dmchengdmcheng

Thanks for your  reply.  Yes I figured SAVEPOINT_ROLLBACK was specifically for savepoints.

 

The odd thing is that the campaign members don't throw exceptions in the Evenbrite sync are  being created.  I'm perplexed as to why the campaign member records can be created but the opportunities are not. 

grigri9grigri9

Interesting. The fact that some of the campaignmembers are being inserted succesfully means that the dmloptions.optallornone parameter is set to false. However, the trigger will run on the entire batch unless the failing campaignmembers are failing before the trigger runs.

 

This is a bit of a guess but perhaps if the "bad" campaignmembers fail after the trigger runs it is not being re-run properly for the valid campaignmembers.

 

Can you check to see that opportunities are created correctly when all campaignmembers in the batch are inserted? If that test works can you paste the debug log here?

 

And can you check to see if the trigger is running on the campaignmembers that fail to insert?