GetDataVariable Method

Microsoft Office InfoPath

Returns a string containing the value of the specified variable, which is a predefined variable stored as a processing instruction attribute in the form's underlying XML document.

expression.GetDataVariable(ByVal lVariableNumber As Long) As String

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

lVariableNumber Required Long. The number of the variable.

returns    String.

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

If the variable is not defined or is empty, the GetDataVariable method will return an empty string. To set a variable, use the SetDataVariable method of the XDocument object.

Note  InfoPath only supports using the initialView variable, which is the variable used to specify the initial view displayed when a form is opened. The number of this variable is always 1, and its value must be the name of a view within the form.

Example

In the following example, the GetDataVariable method of the XDocument object is used to return the value of the first variable:

var strVariable1;
strVariable1 = XDocument.GetDataVariable(1);