Global variables can be passed as static values, asynchronous variable references, interaction event parameters, or filter references.
Global variables are available only in DataV 7.0. Use the new version of the console to access this feature.
Prerequisites
-
You have logged on to the DataV console.
-
Entered Canvas Editor
-
Created two global variables var_1 and var_2
Pass as static value
-
On the Canvas Editor page, click the Global Variables tab.
-
Click var_1 Variable and set Source to Static Value.
-
Modify the content of the initial value to hello.
-
Refresh the
icon next to Data Response Result. -
After the system responds, check that the response result is modified content: hello.
Passing asynchronous values as variable references
-
On the Canvas Editor page, click the Global Variables tab.
-
Click var_1 Variable and change the initial value to datav-hello.
-
Click var_2 Variable and set Source to Data Source Request.
-
If you select API as the data type, use the following procedure.
-
Set Request Method to GET and Input URL to https://datav.com/:var_1.
NoteThis is a sample URL for demonstration purposes and is not accessible. Replace it with your actual URL.
-
Use the F12 function keys on the keyboard to open the call panel.
-
Switch to the Network tab.
-
Refresh the
icon next to Data Response Result. -
Check the Name field on the Network tab again to check whether the Request URL on the Headers tab on the right is a multiple interface.

-
Check the query > api result of the current interface Payload tab for the set value of the var_1 variable.

-
-
If you set the Data Type parameter to Compatible with MySQL Database, perform the following steps:
-
Select Existing Data Source. You can also recreate a data source. For more information, see Data source management.
-
Enter the following SQL expression.
select var_1 as value -
Refresh the
icon next to Data Response Result to view the response results.
-
-
-
If the Data Source Type parameter is set to Static Data or CSV File, global variables are not supported.
-
If the data source type of your widget is API, the system assigns a value directly to the variable that matches the callback ID.
-
DataV supports global variable auto-completion. When you configure a data source, enter a colon (
:). The editor displays all configured variable names on the current screen. Use the arrow keys to select a callback ID and press Enter. This helps you quickly reference global variables, especially when there are many interactive components on the screen.

Pass as an interaction event parameter
-
In the upper-right corner of the Canvas Editor page, click Quick Search.
-
Enter Button and Title to add two widgets to the canvas.

-
Select the Button widget and click the Advanced tab in the right-side Settings panel.
-
Turn on the On Button switch in the Interaction Events section.
-
Select the Global Variable var_1 under the Update to Variable field.

-
Go to the Blueprint Editor page. The global variable and the Button component are automatically connected by a dotted line, showing the reference relationship between them.
NoteWhen you remove a global variable reference, the corresponding dotted line in the blueprint is automatically deleted.

-
In the left-side navigation pane, click the Layer Nodes tab. Drag and drop General Title to the blueprint.
-
The global variable var_2 is connected to the generic header by a solid line.
NoteSolid lines can be deleted, but dashed lines cannot.
-
You can add logical nodes and logical combinations to process the obtained data.
Filter Reference
In the new DataV version, getCallbackValue is the same as getLocalValue. The getLocalValue function is retained for backward compatibility. We recommend that you use getCallbackValue.
-
In the upper-right corner of the Canvas Editor page, click Quick Search.
-
Enter Button and Title to add two widgets to the canvas. Repeat the operation to get the button and generic title components again.

-
Click the Button widget and change the widget names to getLocalValue and getCallbackValue Value.
-
Click the Common Title widget and change the widget names to Common Title -1 and Common Title -2.
-
Click the Global Variables tab and add two global variables named name and test. and set the static values separately.
-
name variable
[ { "value": "The name variable is obtained. " } ] -
test variable
[ { "value": "The test variable is obtained. " } ]
-
-
Set the text content of the two buttons to Get test by getLocalValue and Get name by getCallBackValue.

-
Click the
icon in the upper-left corner to go to Blueprint Editor. -
Connect components.

-
Add a filter and set the processing method of the Serial Data Processing node.
-
getLocalValue
return getLocalValue('test'); -
getCallbackValue
return getCallbackValue('name');
-
-
Click Preview in the upper-right corner of the page to view the details of data retrieval.

FAQ
Q: Why can't I obtain the return value after configuring global variables on the canvas editing page?
A: The canvas editing page cannot trigger events or obtain return values, which causes the request to fail. You can view the callback value by using one of the following methods:
-
Preview the project. View the callback value in the URL, or click the Network tab in the browser console and obtain the value in the response.
-
Edit the project. Add test parameters next to the URL of the visual application to test the data.
https://datav.aliyun.com/v/editor/216? parameter name=parameter value