Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
mkm7460
Contributor II
Contributor II

Get Managed [Space Name] or [Space ID] in the Data Load Editor Script in Qlik Sense SaaS or Qlik Sense Enterprise.

Hello,

Is it possible to get Managed [Space Name] or [Space ID] in the Data Load Editor Script in Qlik Sense SaaS or Qlik Sense Enterprise?

Our QVDs reside in Azure. We want to publish same app in different spaces and load the data accordingly (using the space name in the path of QVD). 

Please assist.

Thanks.

Labels (3)
1 Solution

Accepted Solutions
mkm7460
Contributor II
Contributor II
Author

Hello All,

Apologies it took me a while to respond but i've got it figured out. There is no need for [Space ID] or [Space Name], it can be achieved with [App Name]. Works for both SaaS and Enterprise.

Consider the following setup.

We have managed spaces named - Site1, Site2, Site3 based on the geographical location of each site. Each site uses the same sets of apps and qvd generation apps (and hence the script).

We create the folders in Azure/AWS with the same names so that the QVD Paths are mapped accordingly (for all sites in their respective folder) using variables in Data load editor.

All the app names must start with these site names (only when we publish) before that they can be named as "General" in "shared space", since we want to publish the same app in all spaces/streams.
Example - "General - AppName1", "General - Appname2", "General - AppName3" - These apps will be published to multiple spaces/streams.

When we publish these apps, for each site, we rename them.
Example - the "General - AppName1" will be renamed to (when publishing) "Site1 - AppName1", "Site2 - AppName1","Site3 - AppName1", and so on (only when you are publishing - "General" will still remain as is, in shared space)

Azure folder structure based on the Site Name.
Example - lib: <Azure Data connector>/<folder structure>/

Set all the variables in Qlik Sense Data load editor.

Example - to store qvds according to the site
LET vQVDPath1 = 'lib://DataConn:Azure/$(vCat)/$(vCustomer)/$(vSite)/$(vAppName)/Stg1/';


Following script does the trick in Data load editor of the general app - We get the appname and pick the first part of it (which is the sitename) before the first "space"
Let vSiteName = SUBFIELD(DocumentTitle(),' ',1);

This will populate the vSiteName with "Site1", "Site2", "Site3", and so on based on where the app is published. This should apply to both qvd generation app and dashboard app.

 

 

Additional Complexity -

We need to refresh the apps based on the site location (EST, CST, and so on).
Solution: What I have done is create a single reference table in database (for all sites) and that holds the "site name" and the corresponding variables like "time zone" and others which will be populated in data load editor and the app refreshes accordingly.

Please find attached screenshot.

Please let me know if you have any questions.

HTH.

Thanks.

View solution in original post

5 Replies
MadsNGrathe
Contributor II
Contributor II

I would also love to know this.

One thing to note is that if you are loading from QVDs, you can write your "from" script like this:

Table_Name:
LOAD
    "Field 1",
    "Field 2"
FROM [lib://:DataFiles/QVD_Filename.qvd]
(QVD);

This will load from the datafiles folder in the current space that the app is in. I don't know if that was what you were trying to do, but it might be helpful to others looking for a solution 🙂

mkm7460
Contributor II
Contributor II
Author

Hello All,

Apologies it took me a while to respond but i've got it figured out. There is no need for [Space ID] or [Space Name], it can be achieved with [App Name]. Works for both SaaS and Enterprise.

Consider the following setup.

We have managed spaces named - Site1, Site2, Site3 based on the geographical location of each site. Each site uses the same sets of apps and qvd generation apps (and hence the script).

We create the folders in Azure/AWS with the same names so that the QVD Paths are mapped accordingly (for all sites in their respective folder) using variables in Data load editor.

All the app names must start with these site names (only when we publish) before that they can be named as "General" in "shared space", since we want to publish the same app in all spaces/streams.
Example - "General - AppName1", "General - Appname2", "General - AppName3" - These apps will be published to multiple spaces/streams.

When we publish these apps, for each site, we rename them.
Example - the "General - AppName1" will be renamed to (when publishing) "Site1 - AppName1", "Site2 - AppName1","Site3 - AppName1", and so on (only when you are publishing - "General" will still remain as is, in shared space)

Azure folder structure based on the Site Name.
Example - lib: <Azure Data connector>/<folder structure>/

Set all the variables in Qlik Sense Data load editor.

Example - to store qvds according to the site
LET vQVDPath1 = 'lib://DataConn:Azure/$(vCat)/$(vCustomer)/$(vSite)/$(vAppName)/Stg1/';


Following script does the trick in Data load editor of the general app - We get the appname and pick the first part of it (which is the sitename) before the first "space"
Let vSiteName = SUBFIELD(DocumentTitle(),' ',1);

This will populate the vSiteName with "Site1", "Site2", "Site3", and so on based on where the app is published. This should apply to both qvd generation app and dashboard app.

 

 

Additional Complexity -

We need to refresh the apps based on the site location (EST, CST, and so on).
Solution: What I have done is create a single reference table in database (for all sites) and that holds the "site name" and the corresponding variables like "time zone" and others which will be populated in data load editor and the app refreshes accordingly.

Please find attached screenshot.

Please let me know if you have any questions.

HTH.

Thanks.

AlexOmetis
Partner Ambassador
Partner Ambassador

Just in case anyone lands here looking for a solution to this, it's worth noting that you can now (since July 2023) get this information via GetSysAttr - script and chart function | Qlik Cloud Help

The new script and expression function:

  • Dual GetSysAttr(VariableName)

Variables accessible in this scope:

  • tenantId

  • tenantName

  • tenantUrl

  • tenantUrlAlias

  • tenantRegion

  • spaceId

  • spaceName

  • spaceType

Qlik Partner Ambassador 2024
marc_thomassen
Partner - Contributor III
Partner - Contributor III

@AlexOmetis  thanks for this additional comment. I wasn't aware of this new function. That saves me some time!

theoat
Partner - Creator III
Partner - Creator III

Thank you for your comment !

Enjoy your Qlik.

Kind regards,
Théo ATRAGIE.