How to solve "Default value must be set to a Date literal value" in this scenario?

I have two inputs StartDateInput and EndDateInput. When the user selects both dates and click in the "Search" button, the table should show the records according to the selected dates. This is working using a filter in the agregate.

There is a variable StartDate to hold the value in the StartDateInput and an EndDate variable to hole the EndDateInput

The only issue is that I want to show in this screen the StartDateInput value as the current date minus 1 month and the default value of the EndDateInput as the CurrDate(). However, set the default value of the variable StartDate as AddDays(date, -30) shows "Default value must be set to a Date literal value". 

To solve the issue I add an assign in the preparation after the aggregate with:

        StartDate = AddDays(date, -30)

       EndDate = CurrDate()

And this works, but with an issue: when the screen is acessed at first the StartDateInput appears with the current date minus 30 and the EndDateInput appears with the CurrDate(), this is ok. However, if the user select other dates and click "Search"  the value of the StartDateInput variable is always AddDays(date, -30) and the value of the EndDateInput is always CurrDate(). The issue should because he preparation is executed, so the aggreagate returns always the same reults independently of the dates that the user selected. But Im not understanding how to solve this issue. 



That's right, default value should be a literal, no expressions allowed.

To solve this, you can check on Preparation if the variable is NullDate (StartDate = NullDate())

If it's NullDate, assign it with the Default value you want. If not (already submitted a value), leave the value unchanged.


Hi Oscar,

the refresh button should be set as ajax refresh instead of submit. because on submit the preparation runs again.