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: 
andyjalexlive
Contributor III
Contributor III

Engine API selecting a field value

Hi,

I've recently started to create Mashups using the Engine API. Can someone tell me how i select a value of a field in the Qlik sense app using the Engine API?

e.g. I have a field in my Qlik Sense App called CustomerID and i want to select where CustomerID = 1 

Many thanks

Andy

Labels (4)
6 Replies
ErikWetterberg

Use GetField to get a field object,  then there are some different methods:

andyjalexlive
Contributor III
Contributor III
Author

Thanks for your reply Eric 

I'm trying this but to no avail 

app.getField('CustomerID ')
.then((result) => result.selectValues(10000067)
)

error :

JSON parse error
at Intercept.errorResponseInterceptor (error-response-interceptor.js:1

Do you know what i'm doing wrong?

 

Thanks 
Andy

beatYesterday
Contributor III
Contributor III

 @ErikWetterberg ,

I am able to run the SelectValues after selecting a field in my app, and qReturn= true on response.  However, the table objects in my App are not filtered at all.  Are you able to explain how I can use this SelectValues method and then apply the field selections as a filter to an entire sheet or to a specific table object?  Thank you.

andyjalexlive
Contributor III
Contributor III
Author

Hi 

After selectValues you need to get the result and then invoke a promise to reload your other objects. e.g.

let exampleVisualisationRender= new exampleVisualisation(exampleData)

...

object.selectValues( [
{qText: "1234", qIsNumeric: true, qNumber: 1234}

]).then((result) =>{

Promise.all([ExampleData.open()]).then(() => {
exampleVisualisationRender.init()

})})

 

Hope that helps 

Andy

beatYesterday
Contributor III
Contributor III

Thanks, @andyjalexlive   This reply helped a lot.  For other newcomers like myself while I read the documentation I did not realize a couple of things that prevented the SelectValues method from actually being applied.  Below are the points I (finally) figured out to solve this:

  • Dates are stored as numeric values in Qlik.  This means if you are trying to filter by a date formatted like '2021/02/01'(YYYY-MM-DD), then you need to convert that into it's numeric value.  This numeric value is calculated in teh same way as in Excell, meaning it's just an incremental count of days since 1/1/1900. A simple google search will provide details for how to do this.

 

  • When you are selecting a numeric value, that select match does NOT go in the qText attribute.  Rather, you set qIsNumeric = True AND send the numeric value in the qNumber attribute. (This is what was my  specific problem that I originally outlined above)