You need to sign in to do that
Don't have an account?
Trigger not pulling Account Team members into custom object
Hello - hope someone can help out. I have a custom object, "Services", that tracks customer onboarding post sale.
So when the Opportunity is marked closed won, a trigger will automatically insert a "Services" record for that account - pulling in information from the related Opportunity and Account (Both account and related opportunity fields are custom lookup fields on the Service object, NOT master detail).
What I am trying to do is pull two members from the Account Team of that Account into the Service:
1.) The user marked as the "Integration Manager" on the Account Team will be the Service Owner
2.) The user marked as the "Client Manager" on the Account Team will be pulled into a custom user lookupfield "Client Manager" on the service record
Below is my trigger, attempting to pull from AccountTeamMember
for(AccountTeamMember teamMember:[select id,TeamMemberRole from AccountTeamMember where accountId=:OPP.AccountID]){ if (teamMember.TeamMemberRole=='Integration Manager'){ SVC.OwnerId = teammember.id; } else if (teamMember.TeamMemberRole=='Client Manager'){ SVC.Client_Manager__c = teammember.id; } }
However, I am getting the following error upon save: Error:Apex trigger ServiceCreation caused an unexpected exception, contact your administrator: ServiceCreation: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Client Manager: id value of incorrect type: 01Mn0000000DVyNEAW: [Client_Manager__c]: Trigger.ServiceCreation: line 51, column 1
I think I am pulling the ID of the teammember role, rather than the user itself. Looking through workbench, I can not find the right value to set these users. Can anybody help?
Nevermind...was able to figure it out.
All Answers
Nevermind...was able to figure it out.
I'm trying to add the Account Team member of role = CJ Advertiser Account Director to my custom object Survey in my lookup field Current_AD_Test_c. I am new to coding and this was the closes example of what I was trying to accomplish with my trigger. Is there anyway to look at my code and see where I am going wrong (probably everywhere). Thanks!