Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
UncleRiotous
Creator
Creator

Set a variable's initial value but allow it to be changed by user interaction

I've got a couple of apps where I want to set an initial filter value, etc but I only want it to be done once (if the user changes it I don't want to force them to go back to the default). I've been using Sheet Actions to do that but the process is cumbersome.

I set up variable vChk_DefaultDateSet to be 1 in the variable editor.

UncleRiotous_0-1686039397162.png

Then I have two Sheet Actions (which only work when vChk_DefaultDateSet is 1)

UncleRiotous_1-1686039469557.png

The first action sets the filter for PIV_DAY_DATE but it uses vChk_DefaultDateSet's value to decide whether to leave it as it is or change it the max date in the data using the logic

=If($(vChk_DefaultDateSet)=1,'$(vDate_MaxRecEffDt)',$(vDate_CurrentPivSel))

vDate_MaxRecEffDt is the latest date in the data

vDate_CurrentPivSel is whatever is already selected in PIV_DAY_DATE

UncleRiotous_2-1686039534375.png

The first action sets vChk_DefaultDateSet to zero (so that the next time the sheet action is completed it doesn't change the filter)

UncleRiotous_3-1686039754139.png

 

The solution works but I have to remember to reset vChk_DefaultDateSet to 1 every time I publish the app, if I forget to manually do that then it stops working.

I'd like to load the default value of vChk_DefaultDateSet in the load script but if I do that then the Sheet Action can't change the value.

I can't use a default bookmark to set the filter because the date I'm selecting will change day to day and the default bookmark will set to a value not the output of a calculation/variable.

Anyone got any suggestions for how I can set the default value but still allow it to be amended by a Button, Sheet Action, etc?

 

 

Labels (6)
4 Replies
Or
MVP
MVP

I'm not quite following what it is you're trying to achieve. If the goal is to have a default value but the user can change it, it seems like the correct approach is to use a default bookmark with a dynamic selection, e.g.

=date=Max(Date)

Insofar as the rest of what you wrote, "I'd like to load the default value of vChk_DefaultDateSet in the load script but if I do that then the Sheet Action can't change the value." - I don't quite understand why. There's no technical limitation here that I'm aware of.

UncleRiotous
Creator
Creator
Author

I've never managed to get =date=Max(Date) to work in a bookmark. I've tried a few times and I'm missing something.

I was also sure I'd tested not being able to change variable values I'd set in load script but I checked and you're absolutely right. Thanks for the correction.

Or
MVP
MVP

For the bookmark, you would need to apply this formula and then hit enter (do not select the value with your mouse), then save the bookmark. If you select the value with your mouse, it'll just hard-code that value.

Lokesh_5045
Creator
Creator

@UncleRiotous Creating bookmark based on Max date / today will be a bit tricky.

Step1: Click selections and search for required date field. Select any one value.

Step2: Close the selections. Unselect the value from the field.
Though field name disappears, search bar and drop down values will be there like below.

Lokesh_5045_0-1686168455290.png

 

Step3: Enter the max date expression.
=Date=Max(Date)
Wait for sometime and it shows max date and then hit Enter.
If the above expression doesn't work, try below.
"=Date=Max(Date)"

Step4: Save the bookmark. Now check the bookmark details and you will see like below.

Lokesh_5045_1-1686168656527.png


In my case, I stored max date into vMaxDate variable.