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
MTBRiderMTBRider 

OpportunityTeamMember db errors

I am currently creating opportunity teams in a trigger by inserting into OpportunityTeamMember and then OpportunityShare.  Everything is working on the surface...the team members are getting created.  But when I look into the logs, I am seeing errors when inserting into the team member table:

 

12:20:39.283 (283789000)|USER_DEBUG|[236]|DEBUG|.............The DB Insert failed for the following Opportunity Team Member: 00560000000zDeyAAE
12:20:39.286 (286362000)|USER_DEBUG|[237]|DEBUG|.............The DB returned the following error for the above record: Database.Error[getFields=(Opportunity);getMessage=Required fields are missing: [Opportunity];getStatusCode=REQUIRED_FIELD_MISSING;]

From the message,  I am not quite sure which required field is missing. I am inserting the Opportunity ID, the user ID, and the team role into the team member table.  then for each record that was inserted into the team member  table, I am inserting a corresponding opportunityshare record.  The only other field that looks like it may be required in the OpportunityTeamMember table is the OpportunityAccessLevel column, but that field is not writeable (I assume this column is being updated by a backend process once the opportunityshare record is created).

 

If there are suppose to be three users on the team, there will three sets of the above messages in the logs, yet all three members are showing on the opportunity as team members.  So it appears to be working.  Any ideas why I am seeing this in the logs?  Thanks

jbroquistjbroquist
It would appear the required fields on the Opportunity record you are creating are not all filled out. Can you post your trigger and unit test code so we can help you troubleshoot easier.
MTBRiderMTBRider

Now I cannot replicate the error although I have changed nothing in the code. 

 

...strange and disturbing.