Page 1 of 1

Setting a Date upon Startup

Posted: Wed Jan 24, 2018 1:31 am
by Benrie
What is the best way to set dates upon startup? I have a web app where the user can select beginning and ending dates for search criteria. I want to set these when the web page loads up so they don't have to. How can I do this easily?

Re: Setting a Date upon Startup

Posted: Wed Jan 24, 2018 1:39 am
by jyoung
There are typically two entry points you can hook into.

1. is the CreateInstance Event
2. is the Initialized Event

http://docs.lansa.com/14/en/lansa016/pr ... stance.htm

http://docs.lansa.com/14/en/lansa016/pr ... ialize.htm

The general recommended advice is to use the CreateInstance event.

EDIT
To set the actual dates, if your Field is a date type you can use something like

#StartDate := #STD_DATEX.Now

Once you have a date, there are all kinds of methods to manipulate it in the Date Intrinsics.
http://docs.lansa.com/14/en/lansa016/pr ... insics.htm

Hope this helps,
Joe

Re: Setting a Date upon Startup

Posted: Wed Jan 24, 2018 2:11 am
by Benrie
Thanks Joe! I will give that a try.

Re: Setting a Date upon Startup

Posted: Wed Jan 24, 2018 6:36 am
by Benrie
This solution worked as expected and is giving me the dates as I want. Thanks again!

Re: Setting a Date upon Startup

Posted: Wed Jan 24, 2018 12:34 pm
by atostaine
You can do #startDate := #startDate.now also :D