You need to sign in to do that
Don't have an account?
Bmart
Help with OpportunityTeamMember query and using the Team Member UserId values to a custom object.
Hi everyone. not a developer here so I struggle sometimes with code. I'm trying to create a trigger where when on the Opportunity object I flag the billed complete field (custom field, Jan Billed complete in this example) it queries the opportunity team members of the opportunity and then creates a new CSM Commission record (custom object). I can get everything to work in terms of creating the CSM Commission record, but when creating the CSM record I'm having trouble getting the OpportunityTeamMember who's teammemberrole == 'Client Service Manager' from the CSMTeamMember. Can someone help me out and point out what I need to do? to get the values to feed over correctly? Thanks for your help in advance.
trigger Opportunity_to_CSM_Commission on Opportunity (after update) { // create a set of all the unique line item revision records based on WF ID List<string> CSMIDS = new List<string>(); for (Opportunity o : Trigger.new) { CSMIDS.add(o.id); } Date datobj =date.today(); Integer dy = datobj.day(); Integer mon = datobj.month(); Integer yr = datobj.year(); Integer lastyr = datobj.year()-1; List <CSM_Commission__c > CSMINSERTS = new list <CSM_Commission__c> (); List <OpportunityTeamMember> CSMTeamMember=[Select OpportunityID, Userid, TeamMemberRole from OpportunityTeamMember Where Opportunityid =:CSMIDS ]; for (Opportunity Opp : Trigger.new) { if (/*I want to add a filter here where TeamMemberRole='Client Service Manager' && */OPP.Intl__c == false && OPP.Jan_Billed_Complete__c == true && OPP.Jan_CSM_Payment_Complete__c != true) { CSM_Commission__c CSMCOM= new CSM_Commission__c (); CSMCOM.Opportunity__c = OPP.Id; CSMCOM.Name = 'IO#' + OPP.IO_Number__c + '- January' + yr + '- CSM Payment'; CSMCOM.Jan_Billed__c = OPP.Jan_Billed__c; // CSMCOM.CSM__c = I want to get the OpportunityTeamMember userid where the teamMemberRole = 'Client Service Manager' and assign that person as the CSM__c user lookup value. //CSMCOM.OwnerId= I want to get the OpportunityTeamMember userid where the teamMemberRole = 'Client Service Manager' and assign that person as the Owner of the CSM Commission record. CSMINSERTS.add(CSMCOM); } } try{ insert CSMINSERTS; }catch (System.Dmlexception e) { } }
Below code will help you out.Please udpate the code as per your business requirements:
Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.
Save error: Method does not exist or incorrect signature: [MAP<String,OpportunityTeamMember>].add(String, SOBJECT:OpportunityTeamMember) Opportunity_to_CSM_Commission.trigger /Undertone Sandbox/src/triggers line 15 Force.com save problem