I am trying to display validation rules errors in a VisualForce page I have, but the message isn't showing.

I have the <apex:pageMessages /> tag inside my page and it works for required fields errors, but nothing works for validation rules.

My controller is a standard one, so I can't do a try/catch block to explicitly write the error to ApexPages.addMessage()

Any ideas on this?

  • Is the valdiation rule error message set to display at top of page? If it's set to on field and the field isn't displayed I imagine that could cause this issue.
    – gorav
    Commented May 29, 2017 at 13:14
  • @gorav the VR is set to display at top of the page
    – LuisF
    Commented May 29, 2017 at 13:17
  • This doc, while about custom controllers, appears to indicate that the <apex:messages> component should be used. I know I ran into this recently, can't recall exactly what I did but this seems familiar. Have you tried that option? developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/…
    – gorav
    Commented May 29, 2017 at 13:25

1 Answer 1


Validation rules do cause page messages, but only after Visualforce validation and standard validation (e.g. database-required fields). You'll need to get past any Visualforce validation rules and standard validation rules before you can see custom validation errors.

  • The thing is if I leave a required field blank, the error message shows. If I put some value on the required field, the page saves correctly. This makes me think that there are no more standard or VF validations when I break the VR on purpose to test this...
    – LuisF
    Commented May 29, 2017 at 13:19
  • @LuisF Without seeing your code, it's hard to tell why this might be, but I usually use Database.insert/update(record, false) and then check the results of the save before redirecting. VR can be a bit touchy in Visualforce.
    – sfdcfox
    Commented May 29, 2017 at 13:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .