Share via


XDocument.OnSwitchView Event

InfoPath Developer Reference

Occurs after a view in a Microsoft Office InfoPath 2007 form has been successfully switched.

Version Information
 Version Added:  InfoPath 2003

Syntax

expression.OnSwitchView(pEvent)

expression   An expression that returns a XDocument object.

Parameters

Name Required/Optional Data Type Description
pEvent Required DocEvent An event object that is used during a Office InfoPath 2007 merge or view switching event.

Return Value
nothing

Remarks

This event handler does not allow users to cancel an operation.

Bb229742.vs_note(en-us,office.12).gif  Note
The OnSwitchView event also occurs when a form is first opened.

Example

In the following example, the OnSwitchView event handler is used to check the name of the current view. If the view has the name "Archive Customer," data is added to the form's underlying XML document.

JScript
  function XDocument::OnSwitchView eventObj)
{
   var oDate = new Date();

if (XDocument.View.Name == "Archive Customer") { var oNotesNode = XDocument.DOM. selectSingleNode("/Customers/CustomerInfo/Notes"); var oDivNode = XDocument.DOM. createNode(1, "div", "http://www.w3.org/1999/xhtml");

  oDivNode.text = "Note recorded " + oDate.toString();
  oNotesNode.appendChild(oDivNode);

} }

See Also