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
VladikVladik 

Validation Rules for custom controller

Hi gujs.

I use custom visualforce page and class to create new record of my custom object (override standart "new" button to visualforce page ). This object have a sets of validation rules for 5 different fields.

When I leave these fields blank and try to save the object, then validation error displayed but only for one field. If I fill this field with value and save the object, then error is displayed for next unfilled field.

I want to display all errors simultaneously, but not sequental. But have no idea how to do it.

 

There is a piece of code from my apex class where I instert record

 

 

	public PageReference SaveEvent(){
		try {
			insert ev;
		}
		catch (DmlException e){
			ApexPages.addMessages(e);
			Debug = String.valueOf(e);
			return null;
		}
...
			
			

 

 

 

 

 
           

cloudcodercloudcoder

Have you set the fields as required via Setup-->Create-->Objects-->My Ojbect? If so, the required validation should be handled automagically. You do not need to write custom logic in a controller to handle it.

VladikVladik

Validation rules works, but I if few fields is wrong, visualforce just show error near one field.