Extension Property

Microsoft Office InfoPath

A read-only property that returns a reference to the global scripting object, which exposes the functions and global variables contained in a Microsoft Office InfoPath 2003 form's primary scripting file.

expression.Extension

expression    Required. An expression that returns a reference to an XDocument object.

Security Level

2: Can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

Remarks

The Extension property facilitates using the functions and global variables implemented in an InfoPath form's scripting file. Usually, it is used from a custom task pane, from a custom dialog box, or in the XSL Transformation (XSLT) of a view where direct access to the functions and variables may be needed.

For example, if you were to declare a global variable in your scripting file such as the following,

var constCity = "Redmond";

You could access that value in the code of your custom task pane or dialog box by using the Extension property, as shown here:

XDocument.Extension.constCity;

To use the Extension property within a custom task pane, you must first set a reference to the XDocument object by using the Dynamic HTML (DHTML) external property of the DHTML window object, as shown in this example:

objXDocument = window.external.XDocument;

Example

In the following example, the Extension property of the XDocument object is used to access a custom function:

objXDocument = window.external.XDocument;
objXDocument.Extension.MyCustomFunction();