On a custom page I use an inputField, to make a picklist editable. To make it required I added a validation rule and linked the error location to the picklist field.

enter image description here

But instead of showing up on the field, it loads a new page to only show the error message.

enter image description here

Update failed. First exception on row 0 with id a0Ad000000W8DDOEA3; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Status must be set!: [] Error is in expression '{!doSave}' in component in page up2go_2f:myPage: Class.MY_PREFIX.MyCtrlExt.doSave: line 25, column 1 An unexpected error has occurred. Your development organization has been notified.

I also set it to "Top of Page", same behaviour. didn't help either.


<apex:form id="form">
    <apex:pageMessages />

    <apex:pageBlock mode="edit">

        <apex:pageBlockButtons location="top">
            <apex:commandButton value="Save" action="{!doSave}" rerender="form" />


        // display all the fields I need & do some more stuff


public PageReference doSave() {
    update links;

How can I ensure, the message will be shown on the location I selected when creating the validation rule?

  • can you please add complete error message? – Ratan Paul Jul 19 '16 at 10:34
  • @Ratan pasted it – Basti Jul 19 '16 at 10:42
  • not sure if you got the point ;) please double check the question. – Basti Jul 19 '16 at 10:59
  • yeah looks like links object status field value is not getting binded. can you pls share the complete code.. ? – Ratan Paul Jul 19 '16 at 11:06
  • 1
    if you want to add error on field level then you need to add error like sbject.fieldAPIName.adderror('add error massage '); like this way – Ratan Paul Jul 19 '16 at 11:18

Yes, we can specify where the error message would be displayed. But this applies to standard layouts and not to the custom developed visualforce pages. You need to change your function as to make it work:

public PageReference doSave() {
    update links;
}catch(Exception e){

This will redirect validation messages to visualforce page. The errors would be displayed at the location of <apex:pagemessages /> tag

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.