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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Add G/L Entry Closing Date to API

(0) ShareShare
ReportReport
Posted on by 10

Hello everyone, I am developing a Business Central extension to expose data in custom API pages. I am using the AL development to expose the API. One of my pages needs to include the G/L entry transactions and I need one field that is not present on the table, but it is present on the application.

We know that closing dates will and a "C" on the beginning of the dates. This is also a fictitious date generated by Business Central that will include a timestamp to the dates. G/L Entries that are included on the close income statement batches have a posting_date with this C.

I need to identify such transactions. I am exposing the posting date field on my AL.

In other words, I need to check if that specific G/L Entry is included in a closing batch. 

Which field to use, and how does Business Central mark the G/L Entry with the "C" on the posting date? how to replicate this on an API page?

I have the same question (0)
  • Suggested answer
    Vaishnavi J Profile Picture
    3,094 on at

    Hi,

    To identify closing statement entries in G/L entries table use SourceCode field in GL entries which takes value from close income statement field present in source code setup page.

    pastedimage1651679582841v1.png

    pastedimage1651679612574v2.png

    Also, Posting date contains a prefix 'C' for closing statement is because there is method ClosingDate(Date) which is used to add 'C' as prefix in the date. Refer the below link for more information.

    docs.microsoft.com/.../system-closingdate-method

    If my answer was helpful to you, please verify it so that other users know it worked. Thank you very much

  • gustavonery Profile Picture
    10 on at

    HELLO Vaishnavi Joshi, actually your answer helped me to find out that the source code can be used. However, my need is a little bit deeper. As you can see in the following image, I'm creating a new page of type API. I need to know how to make this in the AL language. I want to return true or false on the field "isCloseIncomeStatement" (line 24)


    Screen-Shot-2022_2D00_05_2D00_05-at-14.38.28.png

  • Suggested answer
    JAngle Profile Picture
    150 on at

    This might give you some direction on how to code that part:

    m.youtube.com/watch

  • Suggested answer
    Vaishnavi J Profile Picture
    3,094 on at

    Hi gustavonery 

    if you are creating your own API and adding one field which is not present in standard API(G/L entries)

    So either you copy the standard G/L entry API v1.0  and paste the entire code in your own API in additional to isCloseIncomeStatement field

    and write a logic onOpenPage Trigger to set the value to true isCloseincomeStatement.

     trigger OnOpenPage()

       var

           RecSourceCode: Record "Source Code Setup";

       begin

           RecSourceCode.Get();

           Rec.SetFilter("Source Code", RecSourceCode."Close Income Statement");

           if Rec.FindSet() then repeat

           Rec.Validate(IsCloseIncomeStatement,true);

    until Rec.Next()=0;

       end;

    If my answer was helpful to you, please verify it so that other users know it worked. Thank you very much

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,958 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,101 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 959 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans