Skip to main content

I have below 2 conditions:

  1. Create the object called “Customer” and create the Master-Detail Relationship on Customer object so that Customer will be the related list to Account record. Create the field called “Account Manager” on Customer object which is lookup to the user object. Now Logic is when we create a Customer record for an account record, then the user in the Account Manager field will be automatically added to the Account Team of that associated account.

I am done with 1st condition for that i have written below trigger.

trigger AccountTeam on Customer__c (before insert) {

    List<AccountTeamMember> atm_list=new List<AccountTeamMember>();

    AccountTeamMember atm = new AccountTeamMember(); 

    if(trigger.isInsert)

    {

        For(Customer__c c:Trigger.new)

        {

            if(c.Account_Manager__c!=null){

                atm = new AccountTeamMember();

                atm.accountid=c.Account__c;

                atm.teamMemberRole='Account Manager';

                atm.UserId=c.Account_Manager__c;

                atm_list.add(atm);

            }

 Now i have 2nd condition  : Now the following trigger logic is when we update the user in the “Account Manager”, the Account team will be updated automatically.

 

Can you please help me with 2nd codition.

 

Thanks in Advance

        }

        if(atm_list!=null)

            insert atm_list; }

1 Antwort
0/9000