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

How to Call a field? Business Central

(0) ShareShare
ReportReport
Posted on by 205

Hey Everyone.

I am trying to perform a mathematical calculation in Business Central, the idea is to run the code automatically every month. I have created a table in General Ledger Setup of interest percentages that will be used to calculate the interest on a payment. I am trying to calculate interest on an amount that will be posted manually by a user. The thing I am struggling with is that how do I retrieve the percentage and # of total days in a year from General Ledger table that I have created meaning what is the command for it. Rough sketch which is not an actual code but more of a pseudocode is shown below,

Table in General Ledger Setup I have created which are editable fields:

Interest Payment = 3%

Total # days year = 365

WHILE

{

Document Type = Invoice;

Posting Date = Date < 20th of the month

DO

{

Document Type = Invoice;

Account Type = G/L Account;

Account No. = Interest Expense;

Description = ‘Interest Invoice’;

Bal. Account Type = Vendor;

Amount = Required Interest Amount;

}

 

{

Procedure Required Interest Amount (): Decimal

Begin

 Interest Calculation Required = Actual Amount * Interest Rate * [(20 Days – Posted Day Actual) + 1 day] / Total # days year;

 

Return Required Interest Amount;

End;

}

  • Suggested answer
    Community Member Profile Picture
    on at

    Create a new variable for example

    GLSetup : Record "General Ledger Setup"

    Then in your code you use the field from General ledger setup.

    GLSetup.Get; //To get General ledger setup record

    GLSetup."Interest Payment" //to access the field

    Look at this link for more detail

    docs.microsoft.com/.../devenv-get-find-and-next-methods

  • Aneeq Profile Picture
    205 on at

    That actually helps. Thank You for that. Another struggle I have on the same note is that when a user posts a transaction, how do i create a criteria that the system needs to check if the posting date for a specific journal was done before 20th of the month and the document type is invoice? I was looking into Event Subscriber but i am not sure if this would work? Or should I use OnValidate () begin .... condition .... end?

  • Suggested answer
    THE Italian Profile Picture
    Microsoft Employee on at

    Use Event Recorder to track the list of events that you could subscribe to and find out what suits you best

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-events-discoverability

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 645 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 432 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 248 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans