KX Community

Find answers, ask questions, and connect with our KX Community around the world.

Home Forums KX Solutions how to do calculation using view state variables and then assign it to another view state

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

    Posted by findpippi on December 14, 2022 at 12:00 am

     

    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:

    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. 

     

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

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

     

    findpippi replied 1 month, 3 weeks ago 2 Members · 1 Reply
  • 1 Reply
  • dlee

    Member
    January 11, 2023 at 12:00 am

    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.

     

    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.

Log in to reply.