function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Surinder Singh 25Surinder Singh 25 

Add Opp Team Member Whose Role is Portfolio Developer to Local Portfolio developer field in Opportunity

trigger AssignCloseOppTeamMember on OpportunityTeamMember (after insert) {
List<Opportunity> OpportunityList = new List<Opportunity>();
Map<Id, Id> OppIdOppMemberIdMap = new Map<Id, Id>();

for(OpportunityTeamMember OpportunityTeamMemberObj: Trigger.New){
    if(OpportunityTeamMemberObj.TeamMemberRole =='Portfolio Developer')
        OppIdOppMemberIdMap.put(OpportunityTeamMemberObj.OpportunityId , OpportunityTeamMemberObj.Id);

for(Opportunity opportunityObj : [Select Id, LocalPortfolioDeveloper__c from Opportunity where Id IN: OppIdOppMemberIdMap.keyset()]){
        opportunityObj.LocalPortfolioDeveloper__c= OppIdOppMemberIdMap.get(opportunityObj.Id).User.Id;
update OpportunityList;

getting error - Compile Error: Initial term of field expression must be a concrete SObject: Id at line 13 column 95
Vijaya Kumar RegantiVijaya Kumar Reganti
Hi Surinder,

I guess the following line causing the issue.

opportunityObj.LocalPortfolioDeveloper__c= OppIdOppMemberIdMap.get(opportunityObj.Id).User.Id;

This line OppIdOppMemberIdMap.get(opportunityObj.Id) -- returns OpportunityTeamMemberId 

But you using "OppIdOppMemberIdMap.get(opportunityObj.Id).User.Id" refering .User from the Id insted put the entire object

OppIdOppMemberIdMap.put(OpportunityTeamMemberObj.OpportunityId , OpportunityTeamMemberObj);

and then this will work.

opportunityObj.LocalPortfolioDeveloper__c= OppIdOppMemberIdMap.get(opportunityObj.Id).User.Id;

Best Regards,

Surinder Singh 25Surinder Singh 25
Thanks Vijay it worked.