web
You’re offline. This is a read only version of the page.
close
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

AL Code for Using Period in Recurring Frequency of Recurring Journal

(1) ShareShare
ReportReport
Posted on by 15,529
Hi Experts 
 
Has any developer here had a success to develop AL code that add Period (accounting period) option into Recurring Frequency of Recurring Journal? This way user can use period to line up frequency with their period. 
 
If yes and if you do not mind can you please share your code? 
 
Thanks 
I have the same question (0)
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,111 Moderator on at
    I do not think you can use the period directly in a date formula.
    You will have to figure out the end date for the next accounting period and use that date or use 1M if you have your accounting periods equal to one month.
     
  • MahGah Profile Picture
    15,529 on at
    Thanks Mr Bruvik 
     
    that is my struggle. Since we are not on month and we use 4-4-5 then I cannot use 4W or 5W (it is changing each month) I was hoping someone came up with development that let period uses in Recurring Frequency 
     
    I saw below code somewhere but that does not look correct. I mean it is for sure what I need but does not look accurate 
     
    tableextension 50100 MyRecurringFrequencyExt extends "Recurring General Journal Line"
    {
        fields
        {
            field(50100; "Recurring Frequency"; Option)
            {
                OptionMembers = D,W,M,Q,Y,P; // Add 'P' for Accounting Period
            }
        }
    }
     
     
    codeunit 50101 MyRecurringLogic
    {
        [EventSubscriber(ObjectType::Table, Database::"Recurring General Journal Line", 'OnAfterValidateEvent', 'Recurring Frequency', false, false)]
        local procedure HandleAccountingPeriodRecurringFrequency(var RecGenJournalLine: Record "Recurring General Journal Line")
        var
            AccountingPeriod: Record "Accounting Period";
        begin
            if RecGenJournalLine."Recurring Frequency" = RecGenJournalLine."Recurring Frequency"::P then begin
                // Fetch the accounting period and set the next posting date.
                AccountingPeriod.SetRange("Starting Date", RecGenJournalLine."Posting Date");
                if AccountingPeriod.FindFirst() then
                    RecGenJournalLine."Posting Date" := AccountingPeriod."Ending Date" + 1
                else
                    // Handle error or custom logic if accounting period is not found.
            end;
        end;
    }
     
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,111 Moderator on at
    Well with accounting periods not following the calendar months i see your struggle.
    I will try to set up the code you provided in a sandbox and see how it works and maybe that will give us some answers if no one else steps in here with a solution before I am able to finish that.
    Do you mind sharing how your accounting periods are set up for a complete fiscal year?
  • MahGah Profile Picture
    15,529 on at
    Hi Mr Bruvik 
     
    Thanks for your help. I have tried to use the code but I have no developer skill and just start learning that. Hence I failed 
     
    We use 4-4-5 which is something like below. As you can see it is not following any months or week. Like the first two periods are 4 weeks then the third is 5 weeks. Also every 6 years we have extra week to cover for all lost days :) but that is not important. 
     
    If code can use accounting period then all is set. 
     
    Thanks for your help here 
     
     
  • LA-13061059-0 Profile Picture
    50 on at
    Hi MahGah
     
    Did you ever resolve this? We are in the same predicament during our project planning! 
     
    Having "Current Period" or CP-1, CP-12 etc. would be so useful.
  • MahGah Profile Picture
    15,529 on at
    Hi 
     
    We could not figure this out as standard way. We added new field that take this formula , then calculate the next posting date and add to next posting date

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,092

#2
YUN ZHU Profile Picture

YUN ZHU 663 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 515

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans