9

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.

1

@DanielBallinger I was able to find a reference to the inconsistent behaviour for OpportunityTeamMember when an Opportunity Owner changes are made from the UI versus the API.

As per the Salesforce SOAP API Developer Guide

"The behavior for changing ownership of opportunities is different using the user interface when the previous owner is on an opportunity team.

For example, when you change the owner of an opportunity using the API, the previous owner's access becomes Read Only or the access specified in your organization-wide default for opportunities, whichever is greater. However, performing this same action in the user interface allows you to select the access level for the previous owner when the previous owner is on an opportunity team".

Although this does not clearly justify the reason of why the trigger does not fire in your case, however, it outlines the variation in behaviour of setting the default access for a previous owner through UI Vs API in case of an ownership change.

  • I've found the trigger doesn't fire with the API or the UI for certain changes. – Daniel Ballinger May 25 '18 at 1:20
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.