I got it to work using this formula on the color base color calculation
=if(getfieldselections (custid)='NOT General, GeneralMFG, PowerPlant, PPR, PPS',rgb(0,170,9),rgb(0,51,170))
This is working for the most part.
We have 4 companies, and all 4 companies do not have the same customers.
So when I click the button when no company is selected, it works fine. If I change companies selected while the button is active it works fine.
The issue is when I select one company, then click the button.
Since this is selecting the above values, then selecting excluded values if a certian company is selected then it changes the string.
PPS Customers- GeneralMFG, PPR
PPR Customers- PPS
Clicking the button when PPS is previously selected displays Not GeneralMFG,PPR
Clicking the button when PPS and PPR are selected displays Not GeneralMFG,PPR,PPS
Having 4 companies there are so many different combinations of selections, it will be dificult for me to base it off of this.
I'm doing similar in an application using macros. For instance, here's one of the macros associated with one of the buttons:
set field = activedocument.fields("Skip Cancelled Order Items?")
set field = activedocument.fields("Steel Grade")
set field = activedocument.variables("740745orders")
The part to notice is in red, where I set a variable to getcurrentselections(). Then the button color can then just compare to that variable:
Now, I do clear all other selections first, so it's not exactly your situation. But I think it would work for your situation as well. Regardless of what other selections have been made, when you press the button and make the desired additional selections, the variable will record the resulting selections. If they subsequently change, it will gray out the button again.
You might be able to do it with actions as well. I haven't tried, but selecting some values and setting a variable seem like things easily done with actions. The only possible problem I see is if QlikView decides to do the actions in parallel, and records the current selections before you've finished selecting.
I am trying the part using the action (due to not knowing or really understanding VB)
I have the button click action as set variable intercompany to getcurrentselection(custid)
When I click the button then check the variable screen, the variable intercompany says:getcurrentselection(custid)
How ever when I test this by creating a listbox and setting the expression to =intercompany it gives me an unavailable code on the window.
Yet, if I replace the expression to exactly what the variable is set to: Getcurrentselection(custid) it works fine.
Is there something I need to do that will record the output of the expression vs the actual expression?
I got it to display by using $(intercompany), however since the variable is set to the expression getcurrentselection(custid) and not the value of getcurrentselection(custid) it is changing the variable based on the selection instead of leaving it set to the selection on button click...
Ok I am slow and my test listbox that I have displaying the variable was wrong.
in the actions setting intercompany=getfieldselections(custid,',',100) works where it is getting the value.
Listbox has expression as field set to:
However your fear seems to be correct, where it is setting the variable before the selection of fields. So if no selections are made, and the button is clicked, it saves a null value to the variable. If the button is clicked a second time, then it saves the correct values.