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

Write Account Team Member to Account as Text or Look-up Field

Does anyone know how to get the value of the Account Team Members to the Account object?  My issue is that I have a custom object with a master-detail relationship to the Account object.  On my custom object, I would like to list one of the Account Team members if they are a certain role.  The only way I can see to do this would be to have the value of the Account Team on the Account level either as a text field or a lookup field.  I don't need it to be a lookup field on my custom object, just the first and last names.  Can anyone help or at least let me know if it's possible?  Thanks




Salesforce not allow write a trigger on Account Team member. So here is possible solution for you.


Solution 1. Provide Custom Button "Add Team" on Account and add account team and populate the any team information on account by using Apex Controller and visualforce.


Solution 2. Add a trigger on Custom Object and get Team member information by use the AccountTeamMember and populate in your custom Object.



Onkar Kumar




Thanks, I was afraid of that.  I need to be able to synch the Account team changes to my custom object, so the trigger needs to fire when the Account team is changed.  I guess my best option is put look-up fields on the Account for each role and then write them down to the Account Team.  I'm not quite sure how to accomplish this so I will poke around a bit.  If you know of any codes, I would appreciate a heads up on it.  Thanks,


I need to be able to do a lookup to the Account Team from an object (I really just want account team fields duplicated on teh account object). Does anyone know how to do this? Am I understanding correctly that the Account Team Object cannot be used in an Apex Trigger, because I was thinking that a trigger might solve my problem. 


#cephan - As far as I know, you cannot write a trigger against the AccountTeamMember object. I had the same issue and to get around it, I created a Text field on the object I needed and used an Apex Trigger to grab the information I needed from the AccountTeamMember object. Now, the only problem with this is that I haven't figured out a way to update the field if the Account team member changes. The only way around this is to literally update the record / object, which will re-import the information.


I'm not the best coder, and this is problem is somewhat knew to me, so I'm sure someone else here has a much better idea and / or code. Also, you have to watch out for no Account Team Members, as it will throw a QueryException.  Also, I am specifically looking for a certain team role in this code, however, there are times when there are two of the same type, so that's why I limit the return result to 1. I have a much bigger code block for dealing with other issues, but this is just a small snippet to help you through your problem.


trigger MyObjectUpdates on MyObject (before update, after insert) {
    for (MyObject myObj :{
            Id samID = [select UserId from AccountTeamMember where AccountId = : myObj.Account_link_id and TeamMemberRole = 'Strategic Account Manager' limit 1].UserId;
            string userName = [select Name from User where Id = :samID].Name;
            myObj.Account_Manager__c = userName;
        catch(QueryException qEx){
            //Do something if no AccountTeamMember; We chose to send an email to the Account Managers to notify them of the missing data


I hope this helps. And, if anyone else has a better route to take, I would love to hear it as the updating is becoming an issue.


Thank you,


Wes Cooper

Xavier Vincent 8Xavier Vincent 8
Hi everyone,

Did someone find a sustainable answer for this specific problem ?
I'm facing exactly the same issue and I can't find any answer anywhere.

Thanks for your time !

Sarah BeutelSarah Beutel

I use a managed package called Declarative Lookup Rollup Summaries Tool to do this. I grabs the Account Team member with a specific title and populates a text field (it's a scheduled run, so doesn't populate live, but I just run it hourly), then I populate the contact record with a forumula based on the text field. One downside is that if someone updates the Account Team by editing, rather than creating deleting and creating a new team member, it doesn't populate. That's pretty easy to manage, though. 

I do recall that you can't find the app by searching in the app exchange, but the publisher is, there's more info on the Github page ( and Chatter group ( Hopefully one of those will give you the info you need.