Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

zrednaz1
New Contributor

Trouble with Capability API - selectValues

I can't get thhe selectValues method to work.

Using the example on https://help.qlik.com/en-US/sense-developer/June2018/Subsystems/APIs/Content/CapabilityAPIs/FieldAPI..., I am trying to set field values using qText values.

For example, I have a Weekday field that looks like this (from app1.field("Weekday").getData()):

weekday.PNG

I've tried selecting values by using:

weekdayField.selectValues([{qText: "Thu"}], false, false);

and

weekdayField.selectValues(["Thu"], false, false);

and

weekdayField.selectValues(["Thu", "Fri"], true, true);

but none of these work. They don't produce a JavaScript error, but they don't do anything.

I am, however, able to select values by index using:

weekdayField.select([1, 3], true, true); <-- works like a charm.

What am I doing wrong since selectValues isn't working?

1 Solution

Accepted Solutions
balabhaskarqlik
Honored Contributor

Re: Trouble with Capability API - selectValues

May be try like this:

An easy way to check if a value has a numeric value is single configurator:

  1. open your app in Single Configurator
  2. in the option pannel under `Apply selections` - click on `Add data`
  3. select field => select value
  4. check your URL

Example from Helpdesk Management app the Filed Dat with value 10/14/2010 is resulting in the URL as `&select=clearall&select=Date,40465` <= `40465`


Refer this link:

app.field('Field').selectValues() Don't work on all fields

4 Replies
balabhaskarqlik
Honored Contributor

Re: Trouble with Capability API - selectValues

May be try like this:

An easy way to check if a value has a numeric value is single configurator:

  1. open your app in Single Configurator
  2. in the option pannel under `Apply selections` - click on `Add data`
  3. select field => select value
  4. check your URL

Example from Helpdesk Management app the Filed Dat with value 10/14/2010 is resulting in the URL as `&select=clearall&select=Date,40465` <= `40465`


Refer this link:

app.field('Field').selectValues() Don't work on all fields

balabhaskarqlik
Honored Contributor

Re: Trouble with Capability API - selectValues

zrednaz1
New Contributor

Re: Trouble with Capability API - selectValues

Bala, you are right. I tried your suggestion and sure enough, "myField.selectValues([43282], false, false);" works.

Unfortunately, this is not very useful to me since I need to set values based on the display values that the following function gives me in the first place:

app1.getList("CurrentSelections", function(reply) {

...

}

This function returns values in the visual format (e.g. "Aug 2018"), but then when I want to set this loaded value later using selectValues, I have to use '43282' instead. Not too intuitive...

Right now it looks like my best bet is to translate the visual value (e.g. "Aug 2018") to an index number by using getData(), then set the value using field.select([indexNo], false, true). It's a bit of a detour, but I'm hoping it will get the job done.

sebastian_serva
New Contributor III

Re: Trouble with Capability API - selectValues

I'm having the exact same challenge. My extension allows users to save the selection state and then re-apply at a later stage. But when re-applying selections, I can't consistently use selectValues, as some of those fields might be in date/numeric format and won't work. 

At the same time, the SelectionObjectDef which is returned by app.selectionState or "CurrentSelections" does not contain the qNum property for each selection value. Just great.

So the challenge is, how do you determine if the field value is a date or not? To Javascript it's just a string. 

Similar to your suggestion, looks like for every selection I want to apply, I'll have to get the field from Sense so that at least I have the qText/qNum equivalent and can determine if I should use the string or number when calling selectValues. A bit of an overkill I wanted to avoid, but can't see any other options at the moment.

Community Browser