I am asked many questions about Business Central on any given day. The questions vary and cover various topics, from development to administration to integration to general application use, to name a few. I want to post them all, but that is not feasible; From time to time, I pick one to write about.
Q. A user received the error “Posting Date is not within your range of allowed posting dates.” How do I set a user’s posting date range of allowed?
A. In Microsoft Dynamics 365 Business Central, the posting date range defines the valid period for financial transactions to be posted in the general ledger.
Usually, the posting date range is set for a fiscal year or accounting period, but it can also be a specific time frame that suits an organization’s needs.
During the posting process of a financial transaction, the procedure IsPostingDateValidWithSetup, found in “User Setup Management,” checks to confirm that a posting date is within the range of the user’s posting date range.
With a quick look at the code for checking the date, I know you wanted to see it. We can see if a User Setup record exists with a date range, then the posting date must fall within that range. If there isn’t a User Setup record, with a date range, for the user, then the date range found on the General Ledger Setup is used.
procedure IsPostingDateValidWithSetup(PostingDate: Date; var SetupRecordID: RecordID) Result: Boolean var UserSetup: Record "User Setup"; AllowPostingFrom: Date; AllowPostingTo: Date; IsHandled: Boolean; begin OnBeforeIsPostingDateValidWithSetup(PostingDate, Result, IsHandled, SetupRecordID); if IsHandled then exit(Result); if UserId <> '' then if UserSetup.Get(UserId) then begin UserSetup.CheckAllowedPostingDates(1); AllowPostingFrom := UserSetup."Allow Posting From"; AllowPostingTo := UserSetup."Allow Posting To"; SetupRecordID := UserSetup.RecordId; end; if (AllowPostingFrom = 0D) and (AllowPostingTo = 0D) then begin GLSetup.GetRecordOnce(); GLSetup.CheckAllowedPostingDates(1); AllowPostingFrom := GLSetup."Allow Posting From"; AllowPostingTo := GLSetup."Allow Posting To"; SetupRecordID := GLSetup.RecordId; end; if AllowPostingTo = 0D then AllowPostingTo := DMY2Date(31, 12, 9999); exit(PostingDate in [AllowPostingFrom .. AllowPostingTo]); end;
If you’d like to specify a Posting Date range for a specific user, create (or modify if it exists) a User Setup and populate the “Allow Posting From” and/or the “Allow Posting To” value. Note: If you fill in only one of the values, then that end of the range has no limit.
To set the Posting Date range for those that do not have a User Setup date range defined, populate the “Allow Posting From” and/or the “Allow Posting To” on the General Ledger Setup. Note: As with the User Setup range, if you fill in only one of the values, then that end of the range has no limit.