See the variable settings and button actions on the attached sample qvw.
I hope it helps you.
testSetVariableOnButtonClick.qvw 136.2 K
In button action -> Add -> External -> Set variable
Now in varaible textbox give your variablename & in value keep this code...
- Then the variable holds the 100 selections of listbox. If you don't give the size then by default the GetFieldSelections method allows you to select only 6 selected values.
I already have the variable set, my issue is that it is being set with the expression.
when I want the results of the above:
How it currently is, the variable is changing with the selection, where I want it to record the actual selected/not selected fields at the time of button click.
Never mind, I see that when adding the = sign before, it is records the values. My test listbox that is showing me what the variable held was malfunctioning.
It is now recording the value of the selection, but now a new issue has apperared.
What the button is actually doing is it is selecting all internal Customer ID's (Internal company selling to another internal company). It is then selecting all excluded values.
this is where I am telling it to record the value of the excluded custid's to the variable. Now that it is working, I see that it is recording the value before the previous actions.
So when no selections are made and I click the button, it records an empty string.
If I click the button a second time, then it records the correct value.
Any ideas how to get around this?
Ok then can you send what field and expression are you using in the listbox...
In the listbox...Field is A and the expressiong is B like this if your listbox looks and data of this fields are:
Load * inline
then try in the variable value like this.
I am not exactly sure what you are asking?
List box is set to an expression:
where intercompany is the variable being set by the button.
It just appears that the action Set variable is executing before the selections are actualy made.
I figured that according to the following image, it would do all the actions in order. Select (cust1|cust2|cust3). Then select excluded custid which changes the selection text to (Not cust1,cust2,cust3) which would then record this into the variable.
However it is not doing that, and when the qvw has no current selections, it is recording '' to the variable, and then setting the selections
I have tested the below and it is working.
You need two variables.
Let use vSelectedRecord for recording and vSpare for checking field selection.
In button actions - Add - External - Set variable
Variavle: vSpare, Value: =if(vSpare, 0, 1)
In Document Properties - Triggers - Variable Event Triggers
Select 'vSpare' as variable, then add two events - Select Excluded and Select Possible in the OnInput event.
And then add Set Variable action like the below in the OnChange event.
Variavle: vSelectedRecord, Value: =getFieldSelections(custid,',',100)
I hope it helps you.