web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

AL Language Reference

(0) ShareShare
ReportReport
Posted on by 45

Hello,

Is there a more comprehensive  AL Language reference available than the one at MSDOCs?

I'm attempting to code around this issue:

https://community.dynamics.com/business/f/dynamics-365-business-central-forum/374591/edm-error-with-odata-feed-and-date-datatype

And would like to know if there are any inbuilt functions in AL to cast columns to other data types.

Any help much appreciated.

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    What do you mean with "comprehensive AL language reference"?

    Your problem listed here seems related to the OData component you're using. A Date field in D365BC is a Datetime under the hood (SQL level). Please try to remove the caption in the query (maybe it's a problem of field name?).

  • Jidl Profile Picture
    45 on at

    Sorry - that wasn't meant to sound like a complaint.

    I've been looking here as a source: docs.microsoft.com/.../devenv-programming-in-al

    If I take the api query object as an example:

    docs.microsoft.com/.../devenv-api-querytype

    The caption property:

    docs.microsoft.com/.../devenv-caption-property

    Is, as far as I can tell, a mandatory field (if I omit it the package compiles and publishes, but goes to an error page). The doc doesn't mention this.

    Maybe it's a function of the language being relatively new - or devs having come over from nav / CSIDE (which I've never used) - but there seems to be lack of reference material. Again - not a complaint - just struggling to find the answers and wondering if there is another source developers are using.

    For the data type issue. My understanding was that the OData component picks up the expected datatypes from a metadata call first? I can't remove the caption. I can't see that I can convert the data type (explicitly cast it as a DATETIME).

    If it's a full date time (i.e., has both data and time values) then it works fine. But '2019-12-10 00:00:00' would throw an error. And '1792-01-01 08:21' would also throw an error.

    Thanks!

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    Caption is not mandatory (recommended, but not mandatory). When you publish an object as an API page a caption should always be placed in camel case notation (for example modifiedDate instead of "Modified Date").

    I mention caption because there are some third party OData components that has problems with OData fields not in camel case format.

    I've never see a problem like yours, Datetime fields in a query and with Odata works without problems (I've lots of Odata components that do that).

  • Jidl Profile Picture
    45 on at

    Great - I hadn't clocked the camel case requirement - I'll give that a go. Thanks!

  • Jidl Profile Picture
    45 on at

    Unfortunately this didn't make a difference.

    Data like the below, with all three being DateTime in the source:

    pastedimage1575999024822v1.png

    With a column on the API page setup like this:

                column(lastDateModified;"Last Date Modified")
                {
                    Caption = 'lastDateModified';                
                } //#62
    Results in this error every time:
    pastedimage1575999112639v2.png
    If I bring through just the Last Modified Datetime it works as expected. So does the Last Modified Time - it's just the Last Modified Date that throws it.
    In addition, if I call the $metadata I get:
    <Property Name="LastDateTimeModified" Type="Edm.DateTimeOffset">...</Property>

    So I'm wondering if it's possible to explicitly cast columns in the query object code?.

  • Suggested answer
    Jidl Profile Picture
    45 on at

    For reference, I found blog.steveendow.com/.../microsoft-dynamics-365-business-central.html to be of enormous benefit.

  • sdjensen75 Profile Picture
    20 on at

    Hi @Jidl,

    Were you able to solve your problem? I am having the same issue with a query where I need Posting Date from G/L Entry.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,010

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,270 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,085 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans