Disable Form Validation When Saving Workflow as a Draft

Again, thanks Dan Huston for a great question which was this:
Is it possible to distinguish between when a workflow form is being submitted and when the user is saving it to their drafts folder?

We have times when the manager does not have certain information and therefore wants to save the form rather than submit it, but the page validation script still fires in this instance.

We certainly can disable screen validation when saving as a draft. Here is the script. As usual, see the principal behind the script and adjust as you require. You might want to have some validation of data for draft…

/**

 * SaveDraft() function is executed in workflow screen when user is saving a draft.
 * This also executes ValidatorOnSubmit() that validates all the information on the form to be consistent.
 */



//save original SaveDraft function 
var orig_saveDraft = window.SaveDraft;

//Override SaveDraft function 
window.SaveDraft = function(){

  // disable validating function
  window.ValidatorOnSubmit = function(){};
 
  // execute original SaveDraft() function
  return orig_saveDraft();
}
This entry was posted in Uncategorized and tagged , , , , , , , . Bookmark the permalink.

3 Responses to Disable Form Validation When Saving Workflow as a Draft

  1. Dan Hutson says:

    Cheers! A huge help as ever.

    I have added your script in to the workflow screen, but it’s still insisting on validating the data. Do I still keep the var orig_ValidatorOnSubmit = window.ValidatorOnSubmit; and it’s function in the script?

    Thanks

    • admin says:

      Dan,
      You don’t need to have that line. What version of HRNET do you use? I have tested this in version 3, but can not guarantee this will work in version 4.

Leave a Reply

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