Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
Thanks in Advance !!
Aniket
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
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.
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.
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
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.
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.
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.