Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

Highlighted
misha_malkovich
New Contributor

selectValues method ignores state

Hi all,

I try to use field api. I have array of string values, field name and state name.

My function in extension is something like this:

function selectByValue(fieldname,value,state){

     var app = qlik.currApp();

     var field = app.field(fieldname,state);

     field.clear;

     field.selectValues(value,true,true);

}

In result. I see all selected values in a field and it ignores state.

How do i use selectValues with state?

Thanks

4 Replies
ErikWetterberg
Honored Contributor

Re: selectValues method ignores state

Hi,

Cool with someone that tries to use state! Have you created the state?

To clear a field you need to call the clear method :

field.clear();  //your example is missing the ()  which means the function will not be called

The clear method returns a promise, which resolves when QIX engine replies to the call. If you want to have control over the order of the calls (and you probably do) you need to wait for the clear before making the selection, like this:

field.clear().then(function(){

field.selectValues(value,true,true);

});

Hope this helps

Erik Wetterberg

misha_malkovich
New Contributor

Re: selectValues method ignores state

Thanks for answer! Tell me please, how create state using api in my function to select values with this state? My function gets only name of state that i want to use.

ErikWetterberg
Honored Contributor

Re: selectValues method ignores state

Hi,

You can create a new state with the addAlternateState method.

Hope this helps

Erik Wetterberg

misha_malkovich
New Contributor

Re: selectValues method ignores state

Thank you very much! It's worked