Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
anothergreg
Contributor III
Contributor III

Trigger to "unselect" not setting variable properly

I have a Field Event Trigger on FIELD1.  OnSelect -> External -> Set Variable vVARIABLE1 using logic below.

=if(GetSelectedCount(FIELD1)>0,'1','0')

I have two text objects to test, because it was working properly temporarily but is now not working any longer.  I have not modified anything with this or any other Trigger or any reference to the variable or field in question.

List Box for FIELD1:

A

B

C

D

Text Box for testing:

=vVARIABLE1

Text Box for testing:

=GetSelectedCount(FIELD1)

The format below will be Selected Values from List Box, vVARIABLE1 test, GetSelectedCount(FIELD1) test

A, 1, 1 - Correct

B, 1, 1 - Correct

C, 1, 1 - Correct

D, 1, 1 - Correct

AB, 1, 2 - Correct

AC, 1, 2 - Correct

AD, 1, 2 - Correct

BC, 1, 2 - Correct

BD, 1, 2 - Correct

CD, 1, 2 - Correct

ABC, 1, 3 - Correct

BCD, 1, 3 - Correct

ACD, 1, 3 - Correct

ABD, 1, 3 - Correct

ABCD, 1, 4, - Correct

none, 1, 0 - INCORRECT BECAUSE vVARIABLE TEST FAILS

If I set an action to clear the FIELD1 field, then test box 1 will work.  The default load is with nothing selected for FIELD1, and test box 1 is accurate.  However, once I select something for FIELD1, I cannot unselect an option and have my vVARIABLE go to 0 as it should.  My Current Selections box shows nothing.  After I deselect the last selected value in the FIELD1 box.

My Qlik workspace is about 200MB and I'm not sure if size would have anything to do with this.  Have I utilized some function within Qlik incorrectly?

Thanks,

Greg

2 Replies
anothergreg
Contributor III
Contributor III
Author

I found that I should have been using an OnChange Field Event Trigger.  The OnSelect was not triggering because when there was nothing selected, it would not get fired.  OnChange fires every time.

anothergreg
Contributor III
Contributor III
Author

As another follow-up, I actually had to use both an OnChange and OnSelect Trigger.  Apparently the OnChange will not work when going from 0 selections to >0 selections, and the OnSelect Trigger will not go from >0 selections to 0 selections.  So using both with the same logic worked.