Dynamics 365 Business Central: How to quickly check whether the posting date is valid in AL (Within the allowed posting date range)

Dynamics 365 Business Central

Hi, Readers.
Today I would like to share another mini tip about Business Central, how to quickly check whether the posting date is valid in AL.

The Posting Date shows when a document was registered in Business Central. Many accounting standards and regulations require businesses to record and report financial transactions based on the date they occurred. For example, on sales and purchase documents.

As you might know, we can use posting periods to specify when users can post to the general ledger. On the General Ledger Setup page, define the period by entering dates in the Allow Posting From and Allow Posting To fields.

These posting periods apply to the company and to all users. To allow for exceptions, you can define different posting periods for specific users on the User Setup page. These posting periods overrule those specified on the General Ledger Setup page.

If the Posting Date is not within the allowed range, the following error will be prompted during posting.

Posting Date is not within your range of allowed posting dates.

So, if we want to do the same thing in our customization, is there a standard way? Of course we can manually compare the values ​​of the two tables, but of course this is not the best way.
This time we can use the CheckAllowedPostingDate method in codeunit 5700 “User Setup Management”.

You can also call the IsPostingDateValid method directly, but you need to write the error message yourself.

Let’s look at a simple example. Add a action on the Sales Order to check if the Posting Date is valid.

General Ledger Setup: 4/1/2024 ~ 4/30/2024

User Setup: 3/1/2024 ~ 4/30/2024

Test: Looks good.

Test video: Youtube

Business Central short video: Check whether the posting date is valid in AL (Within allowed range)

Great, give it a try!!!😁


Hope this will help.

Thanks for reading.



Copied title and URL