You need to sign in to do that
Don't have an account?

Trigger to add new Account team member
Hi Guys,
I have a custom object "Account_Team_Relationship__c" which is related to standard object Account.
Wheneever user is creating new Account_Team_Relationship__c object record, User details (Name, Account Access, Contact Access, Opportunity Access, Case Access and role) should be automaticaly saved to Account Team members, if the user details are not available in Account team members.
As of now Team role can be hardcoded.
Is it possible to do this with trigger?
Your thoughts are highly appreciated.
I have a custom object "Account_Team_Relationship__c" which is related to standard object Account.
Wheneever user is creating new Account_Team_Relationship__c object record, User details (Name, Account Access, Contact Access, Opportunity Access, Case Access and role) should be automaticaly saved to Account Team members, if the user details are not available in Account team members.
As of now Team role can be hardcoded.
Is it possible to do this with trigger?
Your thoughts are highly appreciated.
Mark as best answer, If it resloves !!
upgrade these code based on your requirement
Mark as resloved if it helps :) :)
Thanks,
Bhanu Prakash
visit ForceLearn.com (https://www.forcelearn.com)
I am a newbie to salesforce and not much familiar with triggers.
I tried with below code, but still facing an issue.
trigger AccountTeamChanges on Account_Team_Relationship__c (after insert) {
List<AccountTeamMember> acctMembers = new List<AccountTeamMember>();
List<AccountShare> acctSharingRules = new List<AccountShare>();
for(Account_Team_Relationship__c a : Trigger.new)
{
if(Trigger.isInsert)
{
AccountTeamMember ca = new AccountTeamMember();
ca.AccountId = a.Id;
ca.TeamMemberRole = 'xxxxx';
acctMembers.add(ca);
AccountShare caSharingRule = new AccountShare();
caSharingRule.AccountId = a.Id;
caSharingRule.OpportunityAccessLevel = 'Read';
caSharingRule.CaseAccessLevel = 'Read';
caSharingRule.AccountAccessLevel = 'Edit';
acctSharingRules.add(caSharingRule);
}
insert acctMembers;
insert acctSharingRules ;
}}
Can you post your errors with line numbers