As you all know there are certain "shortcut-keys" for filling date and time fields in NAV, i.e.:- 't' fills in the current date or time ('h' in the Dutch version)- 'w' fills in the workdate
Today a customer asked me why 't' only fills the date part of a datetime field an doesn't return the CURRENTDATETIME.
I already knew that the handling of the string was done by codeunit 1 in the function MakeDateText(..)
After a little digging, I figured out that with modifying the function MakeDateTimeText(..), I could get the result I wanted for DateTime fields.
MakeDateTimeText(VAR DateTimeText : Text) : Integer//BEGIN OF EDIT//Check if the text part of TXT_NOWDate := 0D;Time := 0T;Position := 1;Length := STRLEN(DateTimeText);ReadCharacter(' ',DateTimeText,Position,Length);
IF FindText(PartOfText,DateTimeText,Position,Length) THEN IF PartOfText = COPYSTR(TXT_NOW,1,STRLEN(PartOfText)) THEN DateTimeText := FORMAT(CURRENTDATETIME);//END OF EDIT
IF GetSeparateDateTime(DateTimeText,Date,Time) THEN BEGIN IF Date = 0D THEN EXIT; IF Time = 0T THEN Time := 000000T; DateTimeText := FORMAT(CREATEDATETIME(Date,Time),0,1);END;
Of course the text constant TXT_NOW contains the string 'NOW'.
After adding this code, whenever you put an 'n' in a datetime field, it is filled with the current datetime. (Do not forget to close and reopen your NAV client first because CU 1 is single instance!)
It is possible that this is of course already known to all of you, but well I thought it was quite nifty.
No need to do some programming, this is a better trick: mibuso.com/.../current-date-current-time-current-datetime
Thanks for the tip, problem is in this case our customer wanted a "one character" shortcut. But to be honest, I didn't know your tip :)