Skip to main content

Notifications

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
    Vaishnavi J 3,056 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
    JAngle 33,159 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
    gustavonery 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
    Vaishnavi J 3,056 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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans