How can I get the current date and time. Time() works, but not Date() or System.Date() or System.DateTime, nor does WorkDate or Today work.
Error: Runtime Error xx is an unknown identifier
Today() returns current date
CurrentDateTime() return the current Date and Time
Show me your code?
Erik, it turns out it wasn’t the CurrentDateTime() but it was when I included a DateTime field from a table in the preview message statement. (It works fine if I use a var DateTime field.) This causes error: Message(‘Looking at %1,%2,%3’, SH.”No.”,SH.”CSV Exported DateTime”, SH.”PDF Exported DateTime”);
That’s a bug, I have fixed it here for the next release.
(The bug is that a blank datetime 0DT field in a record doesn’t get stored correctly in ToolBox)
The fix is live in AppSource.
When I use either – I get:
Error message:
Unable to convert from Microsoft.Dynamics.Nav.Runtime.NavJsonValue to Microsoft.Dynamics.Nav.Runtime.NavDateTime.
Internal session ID:
10426c57-96e4-46f8-8000-f699dc2733e9
Application Insights session ID:
633e503c-d914-4166-a195-071329e779ee
Client activity id:
2fdcf0df-79e7-4f38-8cc8-425a04729d30
Time stamp on error:
2025-03-06T19:04:27.4082036Z
User telemetry id:
174f508c-7f4e-428e-9040-3e1fc4002ca6
AL call stack:
Interpreter_Hgd(CodeUnit 70310401).EvalParameterJoker line 26 – AL Compiler and Interpreter by Hougaard
Interpreter_Hgd(CodeUnit 70310401).BuiltInFunctions line 489 – AL Compiler and Interpreter by Hougaard
Interpreter_Hgd(CodeUnit 70310401).EvalFunction line 89 – AL Compiler and Interpreter by Hougaard
Interpreter_Hgd(CodeUnit 70310401).RunStatement line 71 – AL Compiler and Interpreter by Hougaard
Interpreter_Hgd(CodeUnit 70310401).RunStatement line 73 – AL Compiler and Interpreter by Hougaard
Interpreter_Hgd(CodeUnit 70310401).RunStatement line 19 – AL Compiler and Interpreter by Hougaard
Interpreter_Hgd(CodeUnit 70310401).RunIfStatement line 13 – AL Compiler and Interpreter by Hougaard
Interpreter_Hgd(CodeUnit 70310401).RunStatement line 75 – AL Compiler and Interpreter by Hougaard
Interpreter_Hgd(CodeUnit 70310401).RunRepeatStatement line 10 – AL Compiler and Interpreter by Hougaard
Interpreter_Hgd(CodeUnit 70310401).RunStatement line 77 – AL Compiler and Interpreter by Hougaard
Interpreter_Hgd(CodeUnit 70310401).RunIfStatement line 13 – AL Compiler and Interpreter by Hougaard
Interpreter_Hgd(CodeUnit 70310401).RunStatement line 75 – AL Compiler and Interpreter by Hougaard
Interpreter_Hgd(CodeUnit 70310401).RunStatement line 19 – AL Compiler and Interpreter by Hougaard
Interpreter_Hgd(CodeUnit 70310401).RunUnit line 24 – AL Compiler and Interpreter by Hougaard
“Eriks ToolBox Hgd”(Page 70310420).Execute – ToolBox by Hougaard
“Eriks ToolBox Hgd”(Page 70310420).”Editor – SaveRequested”(Trigger) line 5 – ToolBox by Hougaard