cancel
Showing results for 
Search instead for 
Did you mean: 

how to do calculation using view state variables and then assign it to another view state

findpippi
New Contributor

findpippi_0-1671005596878.png

what I plan to do :

to display a pop up, reminding users that end date is earlier than start date, when a wrong end date is chosen and refresh button is pressed.

what I doing is:

findpippi_2-1671005774956.png

add an action for button "refresh", then assign a condition expression 

$[endDate>startDate;alwaysTrue,alwaysFalse] 

to a popup's view state:

isInvalidEndDate

however the pop up will show up no matter if condition expression is true or not. 

findpippi_3-1671006091735.png

findpippi_4-1671006169335.png

inside pop up, the end date and start date is displayed,

So how to control a pop up visibility with other view states?

 

2 REPLIES 2

LeahS
Moderator Moderator
Moderator

Thanks for sharing @findpippi

Welcome feedback from fellow contributors here. 

dlee
New Contributor

Hi findpipi,

The approach I would take to resolve this would be to add a new viewstate called refresh in your button. 

This viewstate would be set to 1b when selected.

dlee_0-1673406625870.png

 

You would then have a query mapper set up to take in your inputs of refresh, startDate and endDate.

Your query mapper would then run something like the following:

{[refresh;startDate;endDate]
$[refresh;
  :$[endDate>startDate; 
    `refresh`popup!(0b;1b);
    `refresh`popup!(0b;0b)
  ];
  :()
]
}

 This way, only when refresh is true, will the check be performed and once the check (regardless of whether endDate is greater than startDate is true and if so set popup to be true)  is completed, refresh will be reset back to 0b so that the check will always occur once the user selects refresh.

 

Hope the above helps.