0

I am trying to display all the OpportunityTeamMember records in a vf page using a wrapper class. But while assigning name in the for loop in the constructor, its throwing an error

Field is not writeable: OpportunityTeamMember.Name

Is there any way to display the name of OpportunityTeamMember

In the constructor i am using -

  oppList = [SELECT Id,Name, OpportunityAccessLevel, TeamMemberRole
                  FROM OpportunityTeamMember where OpportunityId = :opp.id];
        for(OpportunityTeamMember opplis:oppList){
            OpportunityTeamMember oppT = new OpportunityTeamMember();
           Oppswrap inWrap = new Oppswrap (oppT);
            inWrap.oppTeam.Name = opplis.Name;
            wrappers.add(inWrap);
        }

2 Answers 2

0

What is oppTeam in your wrapper, is it an OpportunityTeamMember object? Why not just set the entire oppTeam object to opplis?

inWrap.oppTeam = opplis;
0
0

Few things to consider before moving on to the code

  • Namefield on OppTeamMember is not writable.
  • You need to set the user and OppId in order to make OppTeamMember work. So, record will, which user is part of the team on what "Opportunity".

Code sample

OpportunityTeamMember OppTeamMember = new OpportunityTeamMember();
OppTeamMember.UserId = [UserId];
OppTeamMember.OpportunityId = oppLis.Id;
OppTeamMember.OpportunityAccessLevel='Edit';
OppTeamMember.TeamMemberRole = 'Opportunity Team Member';
inWrap.oppTeam = OppTeamMember;
wrappers.add(inWrap);

Code courtesy of SFDCPoint

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .