Share via


XDocument.SetDataVariable Method

InfoPath Developer Reference

Sets the value of a predefined variable stored as a processing instruction attribute in the form's underlying XML document.

Version Information
 Version Added:  InfoPath 2003

Syntax

expression.SetDataVariable(lVariableNumber, bstrVariableValue)

expression   An expression that returns a XDocument object.

Parameters

Name Required/Optional Data Type Description
lVariableNumber Required Long The number of the variable.
bstrVariableValue Required String The value of the variable.

Return Value
Nothing

Remarks

If the variable being set is not a valid processing instruction attribute, the SetDataVariable method will return an error.

To get the value of a variable, use the GetDataVariable method of the XDocument object.

Bb229817.vs_note(en-us,office.12).gif  Note
Microsoft Office InfoPath 2007 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.

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.

Example

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

JScript
  XDocument.SetDataVariable(1, "View 2");

See Also