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
newbie2010newbie2010 

Handling exceptions

I have a webform that enters data into a custom object in salesforce.  If I don't redirect to a thank you page all of the exceptions get handled automatically showing the visitor they entered data incorrectly or they are missing data and it shows this message under the field in question, but redirects them to a page that says they don't have the rights to view this page.  Once I add the class extension to redirect the page to a thank you page on submittal all that goes out the window.  If any error occurs with this in place, the form pops back up with no message at all leaving the visitor to guess what they have done wrong.  Is it possible to write exception handlers to mimic my first scenario so I can tell the visitor what is missing or incorrect at the corresponding field while also redirecting them to a thank you page?

 

Thanks!!

Pradeep_NavatarPradeep_Navatar

You can use ApexPage.HasMessage(). It is used to determine if your Visualforce Page contains any apex messages. If it contains redirect the Page to the Thank You Page.