Java Script Validation in Workflow

This method no longer works with later versions of HR.Net. See update.

Screen validation has been mastered by me a long time ago and we are using it all over the place.
But workflow screen has not been properly validated before. Today I digged through the page code and discovered the way to do workflow screen validation. It works the same way as screen validation, but you need to override function with different name. See the example below:

var orig_ValidatorOnSubmit = window.ValidatorOnSubmit;

/**
 * If this function returns false, the workflow is not going to be saved. 
 * Beware that you need to show an error message to user, otherwise they would be 
 * left with non-working form and no way of knowing about the problem 
 * If this function returns true, form is going to be saved fine.
 */

window.ValidatorOnSubmit = function(){
  var ErrMsg ='';
  var validate = true;
 
  // your custom validation goes here
	if (!validate){
          alert(ErrMsg);
		return false
	}
	return orig_ValidatorOnSubmit();
}
This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

9 Responses to Java Script Validation in Workflow

  1. Pingback: Java Screen Field Validation | Vizual HR.Net Development: Tips, Tricks and Work-Arounds

Leave a Reply

Your email address will not be published. Required fields are marked *