How to set default value for date

How to set default value for date

  

Hi,

I am using rich widget input calendar for user to select the date. I have a variable to store the date value. I would like to know how can i set a default value for the date? Because if i do not set the default value for the date, the filter inside my aggregate will return no record as the date are compared with 1900-01-01.

Hello Jace,

In preparation, just use an Assignment node and give your default value to the variable associated with the input.

If the variable is a field of a form record, set the value in the source of the form. If you set directly in the form record, it will be overwritten by the source value when server is rendering the page.

Cheers

Eduardo Jauch

Eduardo Jauch wrote:

Hello Jace,

In preparation, just use an Assignment node and give your default value to the variable associated with the input.

If the variable is a field of a form record, set the value in the source of the form. If you set directly in the form record, it will be overwritten by the source value when server is rendering the page.

Cheers

Eduardo Jauch

Actually i am using session variable


Hello Jace. 

Actually, does not matter :)

In any case, you can add an OnSessionStart system event in Logic layer and define the value of the session variable there, to define only in the start of the session and not every time you enter a screen.

You can assign values to session variables the same way you do with local variables.

Eduardo Jauch wrote:

Hello Jace. 

Actually, does not matter :)

In any case, you can add an OnSessionStart system event in Logic layer and define the value of the session variable there, to define only in the start of the session and not every time you enter a screen.

You can assign values to session variables the same way you do with local variables.

Hi,

Thank you.

I have assign the default values of the dates in the preparation but i do not want it to be display it as following.

I want the textbox to be shown as YYYY-MM-DD

How to define only in the start of the session and not every time it enter a screen?



To set only once, add a system OnSessionStart action to server actions and define there. :)

Hi Jace,


To what value are you trying to set your variable to? Fixed date / Future date / Current Date?

I didtn't understand why having it set to 1900-01-01 (NullDate()) is a problem on your aggregate, since you can change the filter conditions to account for it being set like that and still return what you want.


Regards,
João Rosado

Eduardo Jauch wrote:

To set only once, add a system OnSessionStart action to server actions and define there. :)

Do you mind to show an example on how to do this?


João Rosado wrote:

Hi Jace,


To what value are you trying to set your variable to? Fixed date / Future date / Current Date?

I didtn't understand why having it set to 1900-01-01 (NullDate()) is a problem on your aggregate, since you can change the filter conditions to account for it being set like that and still return what you want.


Regards,
João Rosado

Hi,

Actually i do not plan to set any value for the variable, But when i run my application, my aggregate return me no record.

One of the filter function is (PurchaseStartDate >= StartDate and PurchaseEndDate <= End Date).

So when i do debug, i realise my variable for start date is 1900-01-01 and end date is 1900-01-01, thus this appl to the aggregate filter and return no record .


Solution

Hello Jace.
Follow this:

In any case, João Rosado has a valid point.

If the only problem is that you have set up a filter that returns nothing if the date time is "null", you can solve this doing something like this in your filter (this is just an example):

entity.date_field > Session.DateVariable OR Session.DateVariable = NullDate()

This way, if your Date session variable is not defined, you will "turn off" your filter and the entity will not be filtered by the date anymore.

Cheers,
Eduardo Jauch

Solution

Eduardo Jauch wrote:

Hello Jace.
Follow this:

In any case, João Rosado has a valid point.

If the only problem is that you have set up a filter that returns nothing if the date time is "null", you can solve this doing something like this in your filter (this is just an example):

entity.date_field > Session.DateVariable OR Session.DateVariable = NullDate()

This way, if your Date session variable is not defined, you will "turn off" your filter and the entity will not be filtered by the date anymore.

Cheers,
Eduardo Jauch

thanks Eduardo. It work.. :)