Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

shanemichelon
Contributor

Detecting Qliksense stream in Load Script

Hi.  In order to make development and Live a bit easier, I would like to set up my Qliksense load scripts to sense that they are in the Live stream or not.

The idea is that if they are in a non-live stream, then they should load and save data to the testing QVD folder.

This way, when an app is published its load script is identical in dev and live.

I do not care if it is done using tags or detecting the apps stream.

Any suggestions?

1 Solution

Accepted Solutions
shanemichelon
Contributor

Re: Detecting Qliksense stream in Load Script

I have the solution now.  Use the following code:

LET vDocumentTitle = DocumentTitle();
IF right(vDocumentTitle,3)='Dev' then
  LET vAppStatus = 'Dev';
  SET vQVDLib = lib://QS Data - Testing/;
Else
  LET vAppStatus = 'Live';
  SET vQVDLib = lib://QS Data/;
End If

//Usage :  LOAD * FROM [$(vQVDLib)StockItem.qvd] (qvd);

Basically it detects if the app is dev or live.  Then, just add 'Dev' to your apps and use the replace option when publishing to replace the non dev versions.  When you do this, it keeps your dev version for you to continue your work.

3 Replies
undergrinder
Valued Contributor II

Re: Detecting Qliksense stream in Load Script

Hi!

I've had similar problem and I've not found solution for stream detecting.

I recommend you two workaround:

  1. Add flag variable to load script, then with IF statement diferentiate the blocks. You always have to manipulate the script.
  2. Create an application that save data, and create a task with event trigger for it attached to the original application. You can enable/disable this task based on prod/test purpose.

HTH

G.

shanemichelon
Contributor

Re: Detecting Qliksense stream in Load Script

I think I may have a work-around.  I found a function in the help that returns the app name.  I have set up my Dev apps to be called Dev.  So for instance I have an app called 'QVD Generator Dev'.  When I want it to go live, I use the QMC to publish it.  In the publish options I choose overwrite and select the app called 'QVD Generator'.  Then after the publish the published app is still called 'QVD Generator', but has the new stuff in it, and I still have my Dev app.

So my thinking is to use this function to determine if the app ends in Dev.  If it does then use the test QVD folder, otherwise use the live QVD folder.

I haven't tried it yet!  I'll get back with another post after trying it.

shanemichelon
Contributor

Re: Detecting Qliksense stream in Load Script

I have the solution now.  Use the following code:

LET vDocumentTitle = DocumentTitle();
IF right(vDocumentTitle,3)='Dev' then
  LET vAppStatus = 'Dev';
  SET vQVDLib = lib://QS Data - Testing/;
Else
  LET vAppStatus = 'Live';
  SET vQVDLib = lib://QS Data/;
End If

//Usage :  LOAD * FROM [$(vQVDLib)StockItem.qvd] (qvd);

Basically it detects if the app is dev or live.  Then, just add 'Dev' to your apps and use the replace option when publishing to replace the non dev versions.  When you do this, it keeps your dev version for you to continue your work.