+ Start a Discussion
rameshvpsgrameshvpsg 

Validation rule error message on my custom VF page

Hi,

I have a VF page to enter monthly revenue along with comments and added validation rule to make comment mandatory if revenue is modified. How to populate the validation rule error message in my custom VF top section. Below is my VF page. Please suggest.

 

 

 

<apex:page standardController="Price_Book__c"  tabStyle="Price_Book__c"

sidebar="false" extensions="MultipelRevenueEditFee" >

 

<apex:panelGroup rendered="{!Price_Book__c.Checkbox__c==false}" >

 

<apex:form >

<apex:pageBlock >

<apex:pageMessages />

<apex:pageBlockButtons >

    <apex:commandButton value="Save & Return to Forecast" action="{!save}"/>  

    <apex:commandButton value="Save & Return to Opportunity" action="{!return1}"/>

    <apex:commandButton value="Cancel" action="{!cancel}"/>

    </apex:pageBlockButtons>

<table width="100%">

<tr>

    <th width="1%" align="left"></th>

    <th width="15%" align="left"><h1 style="font-size:12pt">FINANCE</h1></th>

</tr>

</table>

 

<hr/>

<table width="100%">

<tr>

    <td width="8%"><b>Service Family</b></td>

    <td width="8%"><b>Record Type</b></td>

    <td width="8%"><b>App Name</b></td>  

    <td width="10%"><b>Date</b></td> 

    <td width="8%"><b>Forecast</b></td>

    <td width="20%"><b>Comments</b></td>

  

</tr>

<tr><td><br/></td></tr>

<apex:repeat value="{!rev}" var="revenue">

<apex:repeat value="{!price}" var="p">

<tr>

    <td width="8%"><apex:outputField value="{!p.FTE_Based_Services__c}"/></td>

    <td width="8%"><apex:outputField value="{!p.RecordTypeId}"/></td>

    <td width="8%"><apex:outputField value="{!p.Related_FTE_Service__c}"/></td>

    <td width="10%"><apex:inputField value="{!revenue.Date__c}"/></td>   

    <td width="8%"><apex:inputField value="{!revenue.Total_Value_by_Forecast__c}" style="width:90pt"/></td>

    <td width="20%"><apex:inputField value="{!revenue.Comments__c}"/></td>

  

</tr>

</apex:repeat>

</apex:repeat>

</table>

</apex:pageBlock>

</apex:form>

</apex:panelGroup>

 

</apex:page>

 

phiberoptikphiberoptik

The page needs to invoke the Save action inorder to cause a validation rule to evaluate it.

goabhigogoabhigo

If you have already created validation rule, and if it is not shown in this VF, then you need to add <apex:pageMessages /> tag after your <apex:page> tag. If this tag is not used and if you make the Comments field mandatory, validation error should be displayed in the field.