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
MCunninghamMCunningham 

DML not permitted UserAccountTeamMember object

HELP !!!
 
I have written a trigger to clone Account team members from a Parent account (into a subordinate account)  but cannot insert the team member privledges as I am getting the error "DML not permitted for UserAccountTeamMember object" !!!
 
What is the reason or approach I should use to do this?
 
 
 
 
Best Answer chosen by Admin (Salesforce Developers) 
tmatthiesentmatthiesen
For Account sharing - you need to create the accountteammember records - as well as update the AccountAccessLevel on the corresponding AccountShare records (which are implicitly created during the accounteammember inserts)

All Answers

tmatthiesentmatthiesen
It seems like you want to replicate the AccountTeamMember objects from the Parent account to the Child account.  To do this, you would query for the AccountTeamMember objects associated to the Parent Account by AccountId - and then insert the corresponding AccountTeamMember objects against the child Account (associating these new shares to the child account by AccountId)

Please note UserAccountTeamMember and AccountTeamMember are two different entities.
MCunninghamMCunningham
Sorry I didnt make myself clear - my trigger already copies the accountteammember records from the Parent to the subordinate - however on creation of the new records it is not possible to set the account access privledge field (restricted field)  Access (it seems) is determined by a corresponding entry in the UserAccountTeamMember object (or thats where my investigation has led) -

this last object does not seem to permit DML access (persumably to stop hotshots writing Apex to amend their own privs) -so at the moment my trigger can clone the account team members to the subord. record - but they only get the access granted by their role heirarchy.

I need to copy the Edit privs from the parent AccountTeamMember records too (so that Key Account Teams can have edit access regardless of role heirarchy) - how can this be done? 

is DML access to UserAccountTeamMember hardwired ? or perhaps can it be relaxed?

btw - what did u mean by "associating these new shares to the child account by AccountId"
MCunninghamMCunningham

I guess Ive misunderstood the roles of these objects - so I'll try to ask the question without my pre-conceptions;-

please advise into which objects must (and may) I insert the records I need to grant an account team member edit access to Accounts and Opportunities..

 
tmatthiesentmatthiesen
For Account sharing - you need to create the accountteammember records - as well as update the AccountAccessLevel on the corresponding AccountShare records (which are implicitly created during the accounteammember inserts)
This was selected as the best answer
MCunninghamMCunningham
thanks for the help - tmatthiesen very much appreciated.