function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NervosaNervosa 

Can a validation rule function as a conttroller on a VF page?

Can a validation rule function as a conttroller on a VF page?

 

I made a very simple validation rule and want now to see a VF page, that is already done too. As far as i understood validation rule should be its controller, but i can't find out how to do it exactly.

 

 http://www.salesforce.com/us/developer/docs/pages/index.htm - i've found this, but it is not my case, because i want to be thrown to my VF page when validation rule fires, otherwise i want to see interface by default.

 

Can you help me?

bob_buzzardbob_buzzard

A validation rule can't be a controller - a controller is either standard and provided by the platform or one that you have written in Apex code.  

 

Are you trying to redirect the user to a visualforce page in the event that a validation rule fails, or are you trying to display a validation rule failure in a visualforce page, or is it something completely different?

NervosaNervosa

I want a VF page to be shown when my validation rule is triggered.

It looks like this - user adds a new item to the stock and when he enters release date that is later than today and clicks Save he sees a VF page with an error.

bob_buzzardbob_buzzard

You can't do that I'm afraid - a validation rule adds error information to the record that is being saved and returns the user to that page. If you need this behaviour, you'll need make the record create/edit a visualforce page.