Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

boonhaw_tan
New Contributor III

Select date using selectValues api

Hi All,

I have a multiple html pages mashup but i having problem to preserve current selection between html pages.

Thus, i tried to using browser sessionstorage method to store current selection made in page A then retrieve the selection from sessionstorage in page B and using selectValues api to perform pre-select.

I able to selectValues() for interger and text but i having problem to use selectValues for selecting date.

Kindly advice how can select date using selectValues.

app.field('customer_name').selectValues(["Peter"], true, true) -> working

app.field('year').selectValues([2014], true, true) -> working


app.field('date').selectValues(['1/7/2013'], true, true) -> not working


Thanks.

5 Replies
boonhaw_tan
New Contributor III

Re: Select date using selectValues api

Hi akl‌ would need your help on selectValues for date.

Luminary
Luminary

Re: Select date using selectValues api

You need to make sure you use the same format as in your app. And remember the display format can be different than the data format on the field level. So look into your datamodel what format your using, and use the same.

Otherwise use the date as a number when it passed. And make sure that the date field has no timestamp in it.

If you want to be sure then format your date like: date(floor(datefield),"d/m/yyyy") as date then your code should work.


Employee
Employee

Re: Select date using selectValues api

Hi boonhaw.tan,

seebach‌ is right, It looks like your field "date" has a numeric value, so you will probably have to pass an object with qIsNumeric: true and qNumber: _value_number_ (SelectValues method ‒ Qlik Sense)

But what I recommend you to use in that specific case is selectMatch instead (selectMatch method ‒ Qlik Sense), this method will automatically try to match the date.

Regarding keeping current selections between mashup pages, you can find a good thread here: Re: Keep current selection between mashup page

I hope this helps,

jasonmomoa
Contributor

Re: Select date using selectValues api

Hi boonhaw.tan,

Field API selectValues() method allows either string or numeric values in the array. However, for dates you must use the numeric value of the given date. Check how Qlik converts date values in the documentation here.

Then, the equivalent call of

  app.field('date').selectMatch('01/07/2013');

would be

  app.field('date').selectValues([41281]);

in 'MM/DD/YYYY' format. You can check the numeric value using the Num(Date(my_date)) Qlik's function.

All you gotta do now is re-create the same conversion from Qlik to your Mashup qlikDateStringToNum().

Hope that helps :-)

Regards,

jasonmomoa
Contributor

Re: Select date using selectValues api

Hi boonhaw.tan‌, did this solve the issue?

Community Browser