Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
AniketVasadkar2
Contributor
Contributor

Reading Widows Environment Variable in Qlik Sense script during reload

Hi All,

Can we read Windows environment Variable in Qlik Sense script or in QVS files during app reload ?

Our aim would be to use same script across various Qlik Sense environment . If we are able to  to read then we will take decision based on this variable values and switch between logic in reload script.

Qlik Sense version: May 2022 Patch4

FYI @Albert_Candelario 

Thanks in Advance !!

Aniket

 

Labels (1)
3 Solutions

Accepted Solutions
Albert_Candelario

Hello  @AniketVasadkar2,

I do not think is possible to read them directly from Qlik Sense script, but maybe could be possible to read such executing a cmd/powershell code from Qlik Sense and reading/saving the outcome into Qlik Sense variable to afterwards use it on your script.

Powershell

Get-Item -Path Env:

I hope this might help!

Cheers,

Albert

Please, remember to mark the thread as solved once getting the correct answer

View solution in original post

barnabyd
Partner - Creator III
Partner - Creator III

G'day Aniket,

Albert is correct, so the method we use to determine which environment we're in is a bit clunky but it works. We name the Qlik Sense app with a suffix to indicate the environment, e.g. 'MyApp_DEV', 'MyApp_UAT', 'MyApp' with no suffix for production.

Then in the load script we use the DocumentName() function and take the last three characters to determine the environment.

I think this is a feature that is lacking, we should be able to query on the current Stream that the app is in or the the current host name or the environment variables, but this is the best we have.

Cheers, Barnaby.

Barnaby Dunn
BI Consultant

View solution in original post

marcus_sommer

Sure that ComputerName() or GetRegistryString() aren't available?

Another way to get the environment-information might be store it within an include-variable - just placed in the environment root.

View solution in original post

4 Replies
Albert_Candelario

Hello  @AniketVasadkar2,

I do not think is possible to read them directly from Qlik Sense script, but maybe could be possible to read such executing a cmd/powershell code from Qlik Sense and reading/saving the outcome into Qlik Sense variable to afterwards use it on your script.

Powershell

Get-Item -Path Env:

I hope this might help!

Cheers,

Albert

Please, remember to mark the thread as solved once getting the correct answer
barnabyd
Partner - Creator III
Partner - Creator III

G'day Aniket,

Albert is correct, so the method we use to determine which environment we're in is a bit clunky but it works. We name the Qlik Sense app with a suffix to indicate the environment, e.g. 'MyApp_DEV', 'MyApp_UAT', 'MyApp' with no suffix for production.

Then in the load script we use the DocumentName() function and take the last three characters to determine the environment.

I think this is a feature that is lacking, we should be able to query on the current Stream that the app is in or the the current host name or the environment variables, but this is the best we have.

Cheers, Barnaby.

Barnaby Dunn
BI Consultant
marcus_sommer

Sure that ComputerName() or GetRegistryString() aren't available?

Another way to get the environment-information might be store it within an include-variable - just placed in the environment root.

barnabyd
Partner - Creator III
Partner - Creator III

Thanks Markus, you're right but most clients where I have worked have multiple environments on a single Qlik Sense instance. In QlikView I would use the path of the QVW file as the reference point. The obvious equivalent in Qlik Sense is the Stream, which unfortunately we don't have.

Aniket - my comment would be to keep it simple. There are probably fancy ways to do external scripts that will work, but if you're just trying to get the job done, the suffix on the app name is the simplest way to go.

Cheers, Barnaby.

Barnaby Dunn
BI Consultant