Global Script Variables
In previous lessons, we worked with local script variables. They were defined with the var function within a single script block. The value was only accessible within that specific block and couldn't be accessed from outside.
Global script variables are defined as "own standing object on story level". This means that they can be accessed from all script blocks within the story.
In the example below, you can see an SAP Analytics Cloud story Outline tab and Script Variable panel. You can:
- Create a new script variable in the Outline tab of a story
- Name the script variable
- Select the data type of the script variable
- Enable the script variable to be used as a URL parameter. For array type variables and nonprimitive type variables (types other than string, boolean, integer, and number), the URL parameter function doesn't apply and the option is disabled by default.

Using global script variables, you can pass a parameter from the URL into the story. For example, you could:
- Pass a value that is used as filter for a dimension
- Pass a value that is used to define a specific layout
When you want to pass a global script variable as URL parameter, you must prefix the variable name with p_ in the URL using the following format: <yourAppURL>&p_<VariableName>=<VariableValue>.
For example, <yourAppURL>&p_viewMode=condensed. This scenario is used in an exercise, so you will see the steps in creating it later in this lesson.
Note
Performance: Where possible, use local script variables over global script variables.Property Binding
In previous lessons, you looked at defining items for the widget manually using direct input and dynamically using scripting. In this lesson, we will look at defining the items dynamically for the widget using property binding.
The property binding function offers the story designer the option to bind the values to one of the following objects:
- Script variables
- Model variables
- Tile filters and variables
Widget value binding is an easy way to create dynamic values for properties, for example, items of a List Box widget.
In the example below, you can see a list box that shows the defined filter values of the table. The selected entry is written back to a global script variable.

A simple widget's value can be bound to one of the following:
- Primitive-type script variable
- Application property
- Tile filter and variable
- Model variable
Note
The supported types vary with each widget.
Supported Binding Types by Widget
Value binding is available for various different widgets. The following list gives you an overview of the widgets and the supported binding types:
- Drop Down Box, Checkbox Group, Radio Button Group
- Bindable values: ID, Display Text
- Supported bindings: Script Variable, Tile Filter & Variable and Model Variable
- Input Field, Text Area
- Bindable values: IDText
- Supported bindings: Script Variable, Tile Filter & Variable, Model Variable and Story Property (including Current User/Time/Date, Last Modified Date, Last Modified Date/Time, Last Modifier, Creator)
- Slider
- Bindable values: Current value
- Supported bindings: Script Variable, Tile Filter & Variable, Model Variable
- Range Slider
- Bindable values: Start value and End Value
- Supported bindings: Script Variable, Tile Filter & Variable, Model Variable
- Image
- Bindable values: Image URL
- Supported bindings: Script Variable
You can also make use of the option of the Write-Back at Runtime feature. With this you can automatically assign the value a user selected to a global script variable that might get used in other scripts or widgets.