Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
cgT
Creator
Creator

Changing Variable Value When Field Is Cleared Of Selections

Hi everyone,

I have a field called 'TransactionDate' which, when I clear it, needs to change the value of a variable, vLastWeekTrans, to 0.

I'm trying to use the current expression in the variable's 'Definition' box and am not getting any result:

=if(GetSelectedCount(TransactionDate)<1, 0,1)

Thanks in advance for any help. 

Labels (1)
1 Solution

Accepted Solutions
Sabrina_V
Partner - Creator II
Partner - Creator II

In your buttons you force the value of your variable vLastWeekTrans to  1 => It's clear th definition.

Two solutions : 

1. In the definition of the variable put the formula if(GetSelectedCount(TransactionDate)<1, 0,1) (without the equal sign) and nothing in the button 

2. If you absolutely want the action on the button : create the variable without definition and then in each button on the action on the variable put the formula if(GetSelectedCount(TransactionDate)<1, 0,1) (without the equal sign)

View solution in original post

10 Replies
Sabrina_V
Partner - Creator II
Partner - Creator II

It works for me

Sabrina_V_0-1682345735715.pngSabrina_V_1-1682345760289.png

Definition of the variable if(GetSelectedCount(TransactionDate)<1, 0,1) (without the equal sign)

cgT
Creator
Creator
Author

Thanks Sabrina,

I've tried this and, once I've updated the definition, it works (i.e. it changes the variable value). I click the button again and then clear the selection and it doesn't work.

Could there be anything that overrules the definition of a variable?

Sabrina_V
Partner - Creator II
Partner - Creator II

Sabrina_V_0-1682347858900.png

 

I try multiple times and it works fine for me. Could you add your app ?

cgT
Creator
Creator
Author

I can add without data if that's ok?

cgT
Creator
Creator
Author

Here is the app. The variable is acting on the background and font colours in the first button on the left underneath the blue banner.

Sabrina_V
Partner - Creator II
Partner - Creator II

In your buttons you force the value of your variable vLastWeekTrans to  1 => It's clear th definition.

Two solutions : 

1. In the definition of the variable put the formula if(GetSelectedCount(TransactionDate)<1, 0,1) (without the equal sign) and nothing in the button 

2. If you absolutely want the action on the button : create the variable without definition and then in each button on the action on the variable put the formula if(GetSelectedCount(TransactionDate)<1, 0,1) (without the equal sign)

cgT
Creator
Creator
Author

This is working really well, thank you Sabrina!

I have one button that's in an alternate state and this method isn't working for that button. Is there an adjustment I need to make when dealing with variables in alternate states?

Many thanks once again.

Sabrina_V
Partner - Creator II
Partner - Creator II

Please see this issue : LINK

cgT
Creator
Creator
Author

The best solution I can seem to find is the following:

if(GetSelectedCount(TransactionDate, 'WoW')<1, 0,1)

'WoW' being the name of the state. The problem is it doesn't clear when the field is cleared of selections.