[SalesForce] Trigger on OpportunityTeamMember is not firing when Opportunity Owner is changed

I'm in a subscriber org where there is an existing trigger on OpportunityTeamMember for after insert, update, and delete.

If you use the UI to add a new team member or edit the opportunity access of an existing team member the trigger fires as expected.

However, if you alter the Opportunity Owner field the opportunity team changes and the trigger does not fire.

By "does not fire" I mean it doesn't appear in the debug log that corresponds with the change in Opportunity Owner and there is no indication that it performed the expected changes. Oddly, the DebugLog operation for the Owner change is waitingJobPage-/0061h000002jhun/a.

Thinking maybe it was some weird UI parallel processing that was hiding the log I temporarily changed the trigger to always fail with a System.assert(false); and performed the owner change with anonymous apex:

Opportunity opp = [Select Id, OwnerId from Opportunity where Id = '0061h000002ji8N'];
opp.OwnerId = '00580000005lhL4';
update opp;

Again, the trigger wasn't hit in any visible log and didn't show any signs of hitting the assertion from the first line.

This seems to agree with the findings in OpportunityTeamMember trigger only fired in some cases – How to get Personal setting, but I can't find any official documentation about the quirks with triggers on OpportunityTeamMember.

I found in following case, the [trigger] will not be fired:

  • “Add Default Team” on Opportunity team related list in Opportunity view layout

  • “Add Account Team” on Opportunity team related list in Opportunity view layout

  • Delete an [opportunity], which will delete OpportunityTeamMember records also

  • Undelete an [opportunity], which will undelete OpportunityTeamMember records also

the OpportunityTeamMember trigger only works with individual add/delete action. [It] does not work with any "group-action" of add/delete

Is there any documentation on the odd behavior of this trigger?

The more official the better.

Best Answer

As some of the cases failed to trigger the Apex Trigger, I did found little mentioning of why they are failing. This Article mentions:

Validation rules and Apex triggers aren’t supported when a user adds his or her default opportunity team on an opportunity.

What else I found out is that even the Process Builders failed to get the trigger along with Apex Trigger in a case when I try to -

“Add Default Team” on the Opportunity team related list in Opportunity view layout

“Add Account Team” on the Opportunity team related list in Opportunity view layout

Additionally, I logged a case with Salesforce to get an Official statement from them.

Related Topic