function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
trigger Accountteam on Account (after update, after Insert) { if(trigger.isAfter){ Id recordType= Schema.SObjectType.Account.getRecordTypeInfosByName().get('Household').getRecordTypeId(); List<AccountTeamMember> lstTeam = new list<AccountTeamMember>(); for(Account objAcc: trigger.newMap.values()){ if(objAcc.OwnerId <> trigger.oldMap.get(objAcc.Id).OwnerId && objAcc.RecordTypeId == recordType ){ AccountTeamMember objAccTeam = new AccountTeamMember(); objAccTeam.AccountId = objAcc.id; objAccTeam.UserId = objAcc.OwnerId; objAccTeam.TeamMemberRole= 'Account Manager'; // you can change the role lstTeam.add(objAccTeam); } } if(lstTeam<> null && !lstTeam.isEmpty()) insert lstTeam; } }
Following is the code to set account team member if owner of the account has changed
Also replace TeamMemberRole with the value you want.
Hope this helps you.
Thanks,
Sukanya Banekar