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

Trigger to update an account field from Child record user names

I am trying to build a trigger that will do the following:


Upon any changes (additions, deletions) to the Account Team related list, will gather the owner alias' of each member and then erase and update a field on the account record.


Example:  Account Team members:  John Doe, Jim Nelson, Peter Downey


On Account Record, a field called "Account Team Members" would then look something like this:  jdoe; jnelson1, pdowney


Each time a related list item is added, deleted or modified, the trigger would rerun to erase and update that field.


I don't have any experience in writing triggers and would greatly appreciate any help from someone who could walk me through this A-Z.


Thanks :)


We can't write triggers on AccountTeamMember object rather what you can do is build a visulforce page by querying all the account team mebers information and display it on detail page.


You mean that you can't retrieve child level information and store it on the parent record in a field?  That doesn't sound correct to me.  There must be some way to accomplish this through a looping command.


I need to build reports of the Account Team and displaying the information on a visualforce page doesn't help me at all.  What I need to do can't be done without storing account team user names or alias' on the account record itself.


Any other ideas?


You can write a trigger on Account and able to retrieve all the child records but the problem is how will this trigger fires when you add a new account team member or delete it.


If you really need to bring these account team members to the account then you need to include a visualforce and bring these values and store it in a field......... I would not recommend this option.


If you are looking for reporting purposes then we have some standard reports which you can utilize, did you tried them?


I did try the standard reports.  Here is my dilemma.  Maybe I'm overlooking the obvious...


Each account record has different sales team members.  There is no rhyme or reason,


I need to be able to view all the opportunities in a report for all the accounts that I am part of the account team.  If I create an account team report, I can't access the opportunities.  If I create an opportunity report, I have no way of filtering out the accounts that I am not part of because the system owns all account records, not the users, so filtering by my accounts is not possible.


I am basically trying to simultaneously pull information from 2 different related lists.  Am I missing something?