You need to sign in to do that
Don't have an account?
Tatiana Cooke 9
Trigger on Opportunity Team
Team,
I thought this trigger was working and I dont know how it is not now. When the secondary owner lookup field is populated on the opportunity I need it to create an opportunity with read write access.
it is only giving the users Read Only access.
Appreicate any help.
I thought this trigger was working and I dont know how it is not now. When the secondary owner lookup field is populated on the opportunity I need it to create an opportunity with read write access.
it is only giving the users Read Only access.
Appreicate any help.
trigger OTOpportunityTrigger on Opportunity (before update) { List<OpportunityTeamMember> listOpptyTeamMem = new List<OpportunityTeamMember>(); Set<Id> OpptyIdSet = new Set<Id>(); for(Opportunity oppty : trigger.New) { //Checking Oppty SecondaryOwner if(oppty.Secondary_Owner__c != null) { OpportunityTeamMember OTM = new OpportunityTeamMember(); OTM.OpportunityId = oppty.Id; OTM.TeamMemberRole = 'Secondary Owner'; OTM.UserId = oppty.Secondary_Owner__c; listOpptyTeamMem.add(OTM); } } if(listOpptyTeamMem.size() > 0) { insert listOpptyTeamMem; // get all of the team members' sharing recordsPost to Community List<OpportunityShare> shares = [select Id, OpportunityAccessLevel, RowCause from OpportunityShare where OpportunityId IN : OpptyIdSet and RowCause = 'Team']; // set all team members access to read/write for (OpportunityShare share : shares) share.OpportunityAccessLevel = 'Edit'; update shares; } }