The documentation page for Static VARA objects states of the Scope field:
This setting can be used to simplify the script that writes values to variables or reads them.
Here is an example. Let’s say you want to access (read/write) a row in a static VARA object where the row name (key name) is the name of the executing user. If the VARA object has the scope Freely selected, then you must specify the key when writing to or reading from the VARA object.
:SET &VARA_NAME# = "UC0.MAL.TEST#1_1.VARA_STATIC_USERNAME"
:PUT_VAR &VARA_NAME#, &$USER#, "Mercury", "Venus", "Earth", "Mars", "Jupiter"
:SET &VALUE# = GET_VAR(&VARA_NAME#,
&$USER#
,1)
:PRINT "Value: &Value#"
If the VARA object has the scope User - each user name, then you can omit the key when accessing the VARA object.
:SET &VARA_NAME# = "UC0.MAL.TEST#1_1.VARA_STATIC_USERNAME"
:PUT_VAR &VARA_NAME#, ,
"Mercury", "Venus", "Earth", "Mars", "Jupiter"
:SET &VALUE# = GET_VAR(&VARA_NAME#,
,1)
:PRINT "Value: &Value#"
Admittedly, the script is not that much simpler. Perhaps VARA scope existed before the Automation Engine provided conveniences like predefined variables for user name, workflow name, etc.
The two scopes that may be a bit more useful are User session and Workflow session. With these two scopes, the default key that is used if none is specified is the user session ID or the workflow run ID, respectively. And importantly, with these two scopes, the rows are deleted from the VARA object when the corresponding session/run ID is removed from the Activity table.
For example, let’s say you want to store some information in a VARA object as long as a user is logged in, but remove the information when the user logs out. You can set the scope of the VARA object to User session - each user session, and put values into the VARA object without specifying a key.
:SET &VARA_NAME# = "UC0.MAL.TEST#1_1.VARA_STATIC_USERSESSION"
:PUT_VAR &VARA_NAME#, ,
"Mercury", "Venus", "Earth", "Mars", "Jupiter"
:SET &VALUE# = GET_VAR(&VARA_NAME#,
,1)
:PRINT "Value: &Value#"
They key used to write the values will be the session ID of the user who runs the script. In my case, running the script caused the following row to be added to the VARA object:
Key | Value 1 | Value 2 | Value 3 | Value 4 | Value 5 |
---|
1168010 | Mercury | Venus | Earth | Mars | Jupiter |
1168010 is the session ID of my user session, visible under Users in Administration (AWI) or System Overview (JUI). As soon as I logged out, this row was removed from the VARA object.
The scope Workflow session - each workflow session works in a similar way. Any row written to such a VARA object (without a key specified) will be automatically removed as soon as the executing workflow is deactivated.