Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a VF page With some inputfield components these fields don't have any validation rules but when i am trying to save the records after entering the details in it. I am getting an error MSG as

Insert failed. The first exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You must review the preferences section before you can save this record.

There are some validation rules on other fields in the same object. According to my requirement I don't want validation fields on my VF page now.

    <apex:page controller="controllerclass">
        .headerRow th{
          <apex:stylesheet value="/sCSS/21.0/sprites/1297816277000/Theme3/default/gc/versioning.css" />
              <apex:tabPanel switchType="client" selectedTab="opportunities2" id="theTabPanel"  >
                  <apex:tab label="tab1" id="Tabone" style="font-weight:bold;width:200px;">
                      <apex:pageblock title="New Lead">
                          <apex:pageblocksection >
                              <apex:form >
                              <apex:commandLink action="{!records}" immediate="true">
                                  <apex:image value="{!$Resource.Logo_Medium}" height="100" width="100" />
                              <apex:commandLink action="{!action}" immediate="true">
                                  <apex:image value="{!$Resource.Logo_Transparent}" height="50" width="200" />
                  <apex:tab label="tab2" id="TabTWO" style="font-weight:bold;width:200px;" name="opportunities2">
                      <apex:form >
                          <apex:pageblock title="Opportunities" mode="edit" >
                              <apex:pageBlockButtons >
                                  <apex:commandButton value="Save" action="{!dosave}" style="Margin-left:250px" immediate="true"/>
                              <apex:pageblocksection >
                                  <apex:pageBlockTable value="{!Opportunities}" var="Opportunity" > 
                                      <apex:column headerValue="RecordTypeId" value="{!Opportunity.RecordTypeId}" />
                                      <apex:column headerValue="Name" value="{!}" />
                                      <apex:column headerValue="StageName" value="{!Opportunity.StageName}"/>
                                      <apex:column headerValue="CloseDate" value="{!Opportunity.CloseDate}"/>
                                      <apex:column headerValue="Sales Representative" value="{!Opportunity.Sales_Rep__c}"/>
                                      <apex:column headerValue="Date Of Appointment" value="{!Opportunity.Date_of_Appointment__c}"/>
                              <apex:pageBlockSection title="Information" columns="2" >
                                  <apex:inputField label="Start" value="{!event.StartDateTime}" />
                                      <apex:selectList label="Sales Consultant" size="1" value="{!Consultantname}" >
                                          <apex:selectOptions value="{!ActiveSalesConsultant}" ></apex:selectOptions>
                                  <apex:inputField label="deal with" value="{!lead.LastName}" />&nbsp;
                                  <apex:inputField label="Duration" value="{!event.DurationInMinutes}"/>&nbsp;
                              <apex:pageBlockSection title="Opportunity Information" columns="2">
                                  <apex:inputField value="{!}"/>
                                  <apex:inputField value="{!ObjOpportunity.StageName}"/>
                                  <apex:inputField value="{!ObjOpportunity.AccountId}"/>
                                  <apex:inputField value="{!ObjOpportunity.CloseDate}"/>
share|improve this question
How about just search for the error text that you encounter and check which validation rule it matches up to. you can then tackle the problem at the source. – techtrekker Dec 10 '12 at 13:52
I see input for LastName, but not for Company. Are you providing that in the controller? Company is a required field unless Person Accounts are enbled. – zjeh Dec 10 '12 at 16:20
up vote 2 down vote accepted

Add the property immediate="true" to your command button.

<apex:commandButton value="Save" immediate="true" action="{!save}"/>

Edited: Refer the link here

share|improve this answer
+1 .Using immediate=true avoids validation – Mohith Shrivastava Dec 10 '12 at 11:59
Thanks Guys for quick Reply I placed Immediate attribute next in commandButton but still I'm getting same error msg System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You must review the preferences section before you can save this record: [] Error is in expression '{!dosave}' in component <apex:page> in page Opportunity – rakesh Dec 10 '12 at 12:08
Which object record you are trying to insert ? – Priyanka Dec 10 '12 at 12:15
Is the error from validation rule or trigger.. Check if the error is from trigger.. Coz immediate=true will only work on validation rules – Priyanka Dec 10 '12 at 12:49
Using immediate=true doesn't just avoid validation rules, it also discards any user input since the last postback. – Bob Buzzard Dec 11 '12 at 8:38

You can't turn off validation rules from a Visualforce page, as per the order of execution from the apex docs:

On the server, Salesforce:

.1. Loads the original record from the database or initializes the record for an upsert statement. .2. Loads the new record field values from the request and overwrites the old values. If the request came from a standard UI edit page, Salesforce runs system validation to check the record for:

• Compliance with layout-specific rules

• Required values at the layout level and field-definition level

• Valid field formats

• Maximum field length  Salesforce doesn't perform system validation in this step when the request comes from other sources, such as an Apex application or a SOAP API call.

.3. Executes all before triggers.

.4. Runs most system validation steps again, such as verifying that all required fields have a non-null value, and runs any user-defined validation rules. The only system validation that Salesforce doesn't run a second time (when the request comes from a standard UI edit page) is the enforcement of layout-specific rules.

Using the immediate=true attribute on a component that submits the page (commandbutton, commandlink, actionfunction) does skip validation, but this is because the user input is discarded, as detailed in a response in this thread from one of the Salesforce product managers:

I've worked around this in the past using a hidden field on the record that is only set via Apex, which indicates to the validation rule that it should allow the record through regardless. I wrote it up a while back in the following blog post:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.