• SanjaykPatidar
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi,
 
I have made a Visualforce page and custom controller for mass adding Sales Team Members for  Opportunities.
I used a newly created list of 5 OpportunityTeamMember records(to be inserted) for iteratively dispalying 5 input sets as in the standard Add Sales Team Page.
 
I wish to have a validation rule which, when the "Save" button is clicked, should add an error message near the TeamRole field of the if it is null.
I tried by the code

Code:
<apex:pageBlockTable value="{!OpportunityTeamMemberList}" var="TeamMember">
..........................
<apex:column headerValue="Team Role">                                           
   <apex:inputField id="inputTeamRole" value="{!TeamMember.TeamMemberRole}" />
</apex:column>
............................
 </apex:pageBlockTable>

 
Code:
if(MyTeamMemberList[index].TeamMemberRole==null)
  
  {     
        
        MyTeamMemberList[index].TeamMemberRole.addError('You must enter a value'); 
        .........       
  }


Problem with this code is that, if the user skips the TeamRole for the second or third input row, the message shows near the Team Role input field in the FIRST input row.
 
How can I add an Error message near theTeam Role inputField of the REQUIRED input row?
Can I use ApexPages.addMessage to input component of the SPECIFIC input row?
 
Thanks in advance
Krishna