Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
Hi akl would need your help on selectValues for date.
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.
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,
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,
Hi boonhaw.tan, did this solve the issue?
Hi @Aiham_Azmeh ,
Is there a problem in using selectValues() for Alphanumeric values?
selectValues() seems to be working only for string values for me and not for Numerical ones.
Can you please provide some code snippet as in how the syntax would be for Alphanumeric/Numeric values?
Would be really appreciated. Thanks in advance!
selectValues will work as long as you convert numeric values to a number array
I haven't solved for date though.
$.each(selection.qSelectedFieldSelectionInfo, function(key,value){
isNaN(value.qName) ? valArray.push(value.qName):valArray.push(Number(value.qName));
});
promiseArray.push(fld.selectValues( valArray, true, true ));
Hello Amit,
I think this might help you,
you can try using following code
app.field('fieldname').selectMatch(match string);
app.field('fieldname').selectPossible();
Thanks & Regards,
Prashant
Prashant,
What does selectPossible after calling selectMatch accomplish?
Though if there are multiple values we have to recurse through the selections to perform selectMatch -> I am hoping to find a way around that.
Thanks,
Amit.