0

I have a requirement where at some places in the visual force page, there should be required fields so I have put this :

<apex:inputfield id="selectId"  value="{!var.field1__c}" required="true" styleclass="mystyle" />

Later I have a custom validation in the controller class that if {!var.field2__c} (That I use to show) is greater than 200, I throw a custom exception (class that extends Exception class) catch it and capture it in <apex:messages styleClass="error_Style" />

Catch(Exception ex) { ApexPages.addMessages(ex) ; }

The thing what is happening is, when i put field1_c empty and field2_c as some value greater than 200 (ex: 300); I get only the required=true error message and not the custom page message that I have. Can anyone tell why is the required error message overriding my custom message? Thanks

1 Answer 1

1

It does't overriding your message. It is just the first exception that occure.

Triggers and Order of Execution on the server, Salesforce:

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.
1
  • Hi Birthus. Thanks for the reply, so from the reply I can see that the only way is to do all validations from the Class and not the page; or everything from the page... is that right?
    – peevesy
    Jan 31, 2014 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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