You need to sign in to do that
Don't have an account?
Trigger for Opportunity Team Member
I have a very simple trigger I've written for adding two text fields to Opportunity Team Member that I then use in a flow. It must be because it's the end of the day and I'm not thinking clearly, but I just need it to line up so that it doesn't mismatch the text values for the users with the actual records. Right now, if I add more than 1 member to the Oppportunity Team, it enters the wrong person's name into Team Member Name and Team Member last name. I just need to get them to match up as they're being entered.
trigger TRG_OpptyTeamMemberName on OpportunityTeamMember (before insert, before update) { List<User> teamMemberInfo = new List<User>(); Set<ID> setTeamMemberID = new Set<ID>(); Integer index = 0; for (OpportunityTeamMember otm: Trigger.new){ setTeamMemberID.add(otm.UserId); } teamMemberInfo = [Select u.Name, u.LastName, u.Id From User u where u.Id in: setTeamMemberID]; for (OpportunityTeamMember otm: Trigger.new){ otm.Team_Member_Name__c = teamMemberInfo[index].Name; otm.Team_Member_LastName__c = teamMemberInfo[index].LastName; index +=1; } }
Can someone please set me straight so that the values align as they go back into the record?
Try this...
All Answers
Try this...
Much appreciated for the assist. Exactly what I needed. Thanks!
For anyone looking at the solution post, the one that works is the first code block out of the two.