Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Adding an alternate state to the document using the Qlik Engine API is pretty straight forward. I know the Alternate State exists and how one can use the alternate state in an expression using set analysis on the visualization objects.
How do we apply the Alternate State to a field object to be used as a filter? If I can't apply an alternate state to a filter object, I can't use the filters within that Alternate state in the expression in my visualization objects.
Do I use GetObject() and then SetProperties() using the qStateName: parameter set from the AddAlternateState method?
Any help?
Regards,
Alex
Resources for others:
By the way, this is a good method to quickly find your object IDs without having to use the single configurator or mess with the APIs just to get a ID
Files added
Mind blown at that shortcut! Great stuff I'll be using this religiously.
Ah, now I see where the confusion comes from.
You are trying to set the filterpane object and not the listbox into a different alternate state.
In Qlik Sense when you drag a field onto a sheet we create a filterpane object.
All the different fields that are shown in the filterpane are created as children to the filterpane.
So when you target the path /qListObjectDef that definition does not exist since you are operating on the filterpane and not the listbox. You probably want to iterate over the filterpanes children and set all its listboxes into a different state. In this specific case the id you are looking for is YPpkPz
Attaching a example that will print out the full property tree of the filterpane to the console just in case you want to look at the hierarchy.
Yea if you can upload the example that would be great. I have yet to get it to work. Please also attach a working example if you could too, this could alleviate a lot of back and forth.
If I put the filterpane object into State Y, the field within that filterpane should inherit the state....or was that just QlikView?
I also couldn't getobject 'YPpkPz' as it returns null
I have the below setup and you can see that the rnmAEX object still gets selected. I guess this is bc my qPath is not correct? How would I include the filterpane in to this path?
That was just QlikView, we don't cascade states in Qlik Sense.
Here is a sample that is working against the app you attached previously, Sales Discovery_ab.qvf
I haven't edited the app at all, just loaded it up using the script attached and refreshed the app after it ran.
Alexander,
Thank you for sticking with it. I noticed a few nuances in the code between what we were working with and your most recent upload. Seems like it liked this one better. Great job!
Some goofiness with the selections in the second state not showing up but logically it makes sense and can be overcome. Can't thank you enough!
Awesome, great that you got it to work.
Yeah the current selections bar shares the same behaviour as in QlikView, i.e it only shows the current selections which is the default state ($). It won't show the excluded state (1), previous selection ($-X) states or any other named alternative states that you add to your app.
Edit: And this is why we love Qlik, at first glance it looks like a simple tool but underneath there is so much complexity going on it makes your mind boogle PS. Don't even get me started on Selected Exluded... .DS
Hi Alex,
Can you also explain little more, where to place the script with in the app using engine api explorer.
Thanks,
Kranthi