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

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?

  • Suggested answer
    Vaishnavi J Profile Picture
    3,058 on at
    RE: Add G/L Entry Closing Date to API

    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

  • Suggested answer
    JAngle Profile Picture
    63 on at
    RE: Add G/L Entry Closing Date to API

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

    m.youtube.com/watch

  • gustavonery Profile Picture
    10 on at
    RE: Add G/L Entry Closing Date to API

    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
    Vaishnavi J Profile Picture
    3,058 on at
    RE: Add G/L Entry Closing Date to API

    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

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,280 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,038 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans