Infopath Form event list description and example use
I. event list:
Name |
Event Handlers |
Description |
DatadomeventObject |
Onbeforechange Onvalidate Onafterchange |
Returns a reference to a form's underlying XML document, the return status, and other properties that contain information about the XML Node during an XMLDocument Object Model (DOM)Change. Also except des a method for raising an error. |
DocactioneventObject |
Onclick |
Returns a reference to a form's underlying XML document, the return status, and the source XML Node during a button click in the form area. |
DoccontextchangeeventObject |
Oncontextchange |
Returns information about the XML Document Object Model (DOM) node that is the current context of the form's underlying XML document. |
DoceventObject |
Onswitchview Onafterimport |
Returns a reference to a form's underlying XML document during a switch view or form merge operation. |
DocreturneventObject |
Onload Onsubmitrequest |
Returns a reference to a form's underlying XML document and the return status during the loading or submission of a form. |
MergeeventObject |
Onmergerequest |
Returns properties and methods that can be used during an onmergerequest event to programmatically interact with a form's underlying XML document and to determine merge properties such as the number of files being merged. |
SaveeventObject |
Onsaverequest |
Returns a number of properties and methods that can be used during a save operation from the onsaverequest event handler to programmatically interact with a form's underlying XML document, determine save properties, and perform the save operation. |
SigneventObject |
Onsign |
Used to add additional data to the digital signature. |
VersionupgradeeventObject |
Onversionupgrade |
Returns a reference to a form's underlying XML document, the return status, and the document and solution version numbers during the version upgrade operation. |
Ii. Example:
// ========
// 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.
}
Function msoxd _ myfield_attr: onbeforechange (eventobj)
{
// Determine whether there is a new value.
If (eventobj. newvalue = "")
{
// The value is blank, so display an error message and roll back the changes.
Eventobj. returnmessage = "you must supply a value for this field .";
Eventobj. returnstatus = false;
Return;
}
}