This function returns the tenant and space domain attributes for a selected app. It can be used in both the data load script and in a chart expression.
The GetSysAttr() function can be used directly in the load script or in a chart expression. In either case, you can use the function to store attributes in a variable, or directly without a variable.
If you use this function in Qlik Sense Client-Managed, it only returns empty data values. Therefore, you can use the function to develop scripts in Qlik Sense Client-Managed without encountering errors, with the intention of later uploading the apps to Qlik Cloud.
Syntax:
GetSysAttr(name)
Return data type: dual
Arguments
Argument
Description
name
The name of the attribute to return. Enter as a string value in the expression. The string value entered is case-sensitive.
You can use the function to load environment attributes into your app. The function can return the following attributes:
Environment attributes that can be returned by the GetSysAttr() function
If the GetSysAttr() function returns an empty spaceId value in Qlik Cloud, this indicates that the app is located in a personal space.
The GetSysAttr() function always returns an empty spaceId value when used in Qlik Sense Client-Managed.
Let vSpaceId = GetSysAttr('spaceId')
=GetSysAttr('spaceId')
spaceName
The name of the space. This is only defined for an app in a shared or managed space.
Information note
If the GetSysAttr() function returns an empty spaceName value in Qlik Cloud, this indicates that the app is located in a personal space.
The GetSysAttr() function always returns an empty spaceName value when used in Qlik Sense Client-Managed.
Let vSpaceName = GetSysAttr('spaceName')
=GetSysAttr('spaceName')
spaceType
The type of space in which the app is located. This is only defined for an app in a shared or managed space.
Information note
If the GetSysAttr() function returns an empty spaceType value in Qlik Cloud, this indicates that the app is located in a personal space.
The GetSysAttr() function always returns an empty spaceType value when used in Qlik Sense Client-Managed.
Let vSpaceType = GetSysAttr('spaceType')
=GetSysAttr('spaceType')
When to use it
This function simplifies space and tenant identification of a Qlik Sense app that might be moved between different environments. The function makes it easy to identify the specific environment you are working in. This is particularly useful during the development, testing, acceptance and production (DTAP) stages of an app's life cycle.
This function can be used in load statements in the app's load script or chart expressions, either directly as an expression or in an expression stored as a variable.
If you anticipate your app being moved between spaces or tenants during its life cycle, use the function in a chart expression to dynamically obtain space and tenant information without reloading the app. When doing so, store the function expression in a variable outside the load script, or use the function directly in the chart expression.
Example 1 – Storing environment attributes as load script variables
In this example, we define a set of script variables that can be used in the app content you create. Each time the app is reloaded, the attributes are evaluated and added to the app.
Do the following:
Create a new Qlik Sense app in a shared space.
Open the Data load editor.
Paste the following load script into a new tab:
Transactions:
Load * inline [
id,date,amount
1,1/1/2023,500.67
2,1/2/2023,458.91
3,1/3/2023,12.34
4,1/4/2023,90.90
5,1/5/2023,256.30
6,1/6/2023,789.16
7,1/7/2023,501.25
8,1/8/2023,87.01
9,1/9/2023,161.16
10,1/10/2023,300.06
];
Let vTenantId = GetSysAttr('tenantId');
Let vTenantName = GetSysAttr('tenantName');
Let vTenantUrl = GetSysAttr('tenantUrl');
Let vTenantUrlAlias = GetSysAttr('tenantUrlAlias');
Let vTenantRegion = GetSysAttr('tenantRegion');
Let vSpaceId = GetSysAttr('spaceId');
Let vSpaceName = GetSysAttr('spaceName');
Let vSpaceType = GetSysAttr('spaceType');
This load script contains the following:
A new table, called Transactions, contains sample transaction data. This could be replaced with any data, and is added as a placeholder.
A series of script variable definitions, for the available attributes that can be fetched by GetSysAttr().
Load the data and open a new sheet in advanced edit mode.
Create a Table object and add the following expressions as dimensions, along with their respective labels:
=vTenantId, with label Tenant ID
=vTenantName, with label Tenant Name
=vTenantUrl, with label Tenant URL (Default)
=vTenantUrlAlias, with label Tenant URL (Alias)
=vTenantRegion, with label Tenant Region
=vSpaceId, with label Space ID
=vSpaceName, with label Space Name
=vSpaceType, with label Space Type
You now have a table in your app that dynamically displays each of the available environment attributes. Exporting the app and uploading it to a different tenant and space would give you these attributes for the newly uploaded version of the app.
Example 2 – Storing environment attributes as variables and using them in chart expressions
In this example, rather than defining variables in the script, we define several variables using the dialog in advanced edit mode. The variables can then be used in chart expressions in the app.
Do the following:
Create a new Qlik Sense app in a shared space.
Open a new sheet in advanced edit mode.
Click to open the variables dialog.
Click Create new.
Under Name, enter vTenantId.
Under Definition, enter =GetSysAttr('tenantId').
Click Create.
This creates an app variable to display the ID of the tenant. Repeat steps 3 to 6 to create a variable for each of the remaining attributes. Use the following parameters:
Tenant Name
Name: vTenantName
Definition: =GetSysAttr('tenantName')
Tenant URL
Name: vTenantUrl
Definition: =GetSysAttr('tenantUrl')
Tenant URL Alias
Name: vTenantUrlAlias
Definition: =GetSysAttr('tenantUrlAlias')
Tenant Region
Name: vTenantRegion
Definition: =GetSysAttr('tenantRegion')
Space ID
Name: vSpaceId
Definition: =GetSysAttr('spaceId')
Space Name
Name: vSpaceName
Definition: =GetSysAttr('spaceName')
Space Type
Name: vSpaceType
Definition: =GetSysAttr('spaceType')
Create a Table object and add each of following expressions as dimensions, along with their respective labels:
=vTenantId, with label Tenant ID
=vTenantName, with label Tenant Name
=vTenantUrl, with label Tenant URL (Default)
=vTenantUrlAlias, with label Tenant URL (Alias)
=vTenantRegion, with label Tenant Region
=vSpaceId, with label Space ID
=vSpaceName, with label Space Name
=vSpaceType, with label Space Type
You now have a table in your app, dynamically displaying each of the available environment attributes. Exporting the app and uploading it to a different tenant and space would give you these attributes for the newly uploaded version of the app.
The main benefit of using the function in chart expressions is that the app does not need to be reloaded for these attributes to be refreshed. This enables smoother movement of apps between tenants and spaces as part of the app life cycle.
Example 3 – Using the function directly in the load script
You can also use the function in your apps without a variable. This example demonstrates how to load a table with each attribute as an individual field. From here, you can create visualizations in the app to display these details.
Do the following:
Create a new Qlik Sense app in a shared space.
Open the Data load editor.
Paste the following load script into a new tab:
Attributes:
Load RowNo() as Key,
GetSysAttr('tenantId') as TenantID,
GetSysAttr('tenantName') as TenantName,
GetSysAttr('tenantUrl') as TenantUrl,
GetSysAttr('tenantUrlAlias') as TenantUrlAlias,
GetSysAttr('tenantRegion') as TenantRegion,
GetSysAttr('spaceId') as SpaceID,
GetSysAttr('spaceName') as SpaceName,
GetSysAttr('spaceType') as SpaceType autogenerate 1;
Load the data. A table is created in the data model, displaying each of the attributes in individual fields.
Now you can use the attribute fields in visualizations, such as tables or text & image objects.
Example 4 – Using the function directly in chart expressions
You can enter the function directly into chart expressions without using a variable.
The main benefit of using the function in chart expressions is that the app does not need to be reloaded to refresh these attributes. This enables smoother movement of apps between tenants and spaces as part of the app life cycle.
Do the following:
Create a new Qlik Sense app in a shared space.
Open a new sheet in advanced edit mode.
Drag a Text & image object onto the sheet.
Click inside the blank chart to add text, and type:
Repeat these steps for the other attributes on new lines, using the expressions presented in the attributes table in the introduction of this help topic.
Load script
The load script is a sequence of statements that defines what data to load and how to link the different loaded tables. It can be generated with the Data manager, or with the Data load editor, where it also can be viewed and edited.
A Qlik Sense or QlikView app: Apps are task-specific, purpose-built applications. Apps contain data loaded from data sources that is interpreted through visualizations.
The Qlik Sense Mobile app: A mobile app for iOS and Android devices. In the mobile app, you connect to and interact with your cloud data. You can work with your available apps.
Sheets are components of Qlik Sense apps. They present visualizations to app users so they can explore, analyze, and discover data. Sheets can be public or private.
A dimension is an entity used to categorize data in a chart. For example, the slices in a pie chart or the bars of a bar chart represent individual values in a dimension. Dimensions are often a single field with discrete values, but can also be calculated in an expression.
A dimension is a dataset in a data mart that forms part of the star schema. Dimension datasets hold the descriptive information for all related fields that are included in the fact table’s records. A few common examples of dimension datasets are Customer and Product. Since the data in a dimension dataset is often denormalized, dimension datasets have a large number of columns.
A field contains values, loaded from a data source. At a basic level, a field corresponds to a column in a table. Fields are used to create dimensions and measures in visualizations.