InfoPath – Display Dialog Box on Load

The first part of the code checks to see if there are any required fields that have no value. If there are, the text displayed in teal is presented to the user and control returns to InfoPath. If no errors are found, the Submit is attempted. If an error of another sort is found, the error message is displayed.

/======= // 
The following function handler is created by Microsoft Office InfoPath. 
// Do not modify the name of the function, or the name and number of arguments.
function XDocument::OnLoad(eventObj)
// Write your code here (Put in Tools…Programming…On Load) 
var clicked
clicked = XDocument.UI.Confirm("This form is for offices with six or fewer employees. Do you wish to continue?", 1);
if (clicked == 1) 
XDocument.UI.Alert("You clicked OK."); 
else if (clicked == 2) 
XDocument.UI.Alert("You clicked cancel."); 

Be sure to enable Submit in the Submittng Forms dialog.

  1. Tools … Submitting Forms.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.