Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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

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

Anonymous
Not applicable
Author

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

Hi,

You can create a new state with the addAlternateState method.

Hope this helps

Erik Wetterberg

Anonymous
Not applicable
Author

Thank you very much! It's worked