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: 
holynumbers
Contributor II
Contributor II

Using variables (GetFieldSelection) in script

I run a Qlik Sense server (April 2019 release when writing this).

Some background...
On the network there is a RapidMiner server which has a web service that the Qlik app can get data from.

In the QlikSense app I want to run a 'Load data' depending on an selection in the app. 
The server is run in 'Legacy Mode' and I use the following connection string and it works.
LOAD *
FROM [http://user:password@server:port/api/rest/process_name?p1=Selection1]
(html, codepage is 28591, embedded labels, table is @1);

I get the data regarding where  p1 = Selection1.

I've created a variable in the app with the name 'vSelection' and definition 'GetFieldSelection(Dimension)'.
When I then change the script to the following:
LOAD *
FROM [http://user:password@server:port/api/rest/process_name?p1=$(vSelection)]
(html, codepage is 28591, embedded labels, table is @1);

When I execute the load script I get and error with the connection where the variable isn't solved:
http://user:password@server:port/api/rest/process_name?p1=GetFieldSelection(Dimension)

How do I do this?

4 Replies
treysmithdev
Partner Ambassador
Partner Ambassador

GetFieldSelection() is not a valid Script function. Are you calling this from the front end? If so, try '=GetFieldSelection(Dimension)' in the variable definition, this way you get the evaluated results of the function and not the function itself. You may need to adjust some of the GetFieldSelection's parameters to match the URL value delimiter and to capture all the selections. By default it only shows 6.

DOC

Blog: WhereClause   Twitter: @treysmithdev
holynumbers
Contributor II
Contributor II
Author

Yes, I understand GetFieldSelection() is not a script function, but I'm not using it in script. I'm using in a variable then using the variable in script. The variable needs to be updated... but the macro variable in script don't seem to be resolved.

If this doesn't work, is there any other way I can get the selected values of a dimension into the script?

mahaveerbiraj
Creator II
Creator II

HI Holynumbers,

I would suggest you use on-demand app generation in qliksense, that will meet your requirement.

Actually its little complex concept use below url and understand the concept ,

https://community.qlik.com/t5/Qlik-Sense-Enterprise-Documents/On-demand-App-Generation-ODAG-in-QlikS... 

 

holynumbers
Contributor II
Contributor II
Author

Hi

That's an interesting idea, but I don't think I can apply an on-demand app in this case.
I want to call a predictive model from RapidMiner  so if I create a on demand app then I don't really get the benefit I'd like.