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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Interest calculation recurring batch job

(3) ShareShare
ReportReport
Posted on by 6
Two months ago, our recurring interest calculation batch job stopped working. We weren't even able to access the parameters, so we had to recreate the job from scratch. 
 
The new job ran on 12/15 for transactions as of 12/12 (To date in parameters). However, we noticed that after the batch job completed and set itself up for the next scheduled run, the To date in the parameters did not automatically adjust like it used to.
 
We have the job recurrence set to the 3rd Monday of every month. It's supposed to use the previous Friday as the To date. 
 
I have nothing in my documentation to explain how we got the To date to adjust each month in the previous version of the job. Can anyone help?
Categories:
I have the same question (0)
  • Suggested answer
    vishalsahijwani Profile Picture
    222 on at
     
    Please check if this code helps your development team and aligns with your requirement : - 
     
    Step 1 - Create a class named as DateHelper and use the below mentioned code : - 
     
    class DateHelper
    {
        public static date getThirdMonday(date _date = systemDateGet())
        {
            int year  = year(_date);
            int month = mthOfYr(_date);
            date firstDate = mkDate(1, month, year);
            int firstWeekDay = dayOfWk(firstDate); // Monday = 1
            int offset;
            if (firstWeekDay == DateWeek::Monday)
            {
                offset = 14;
            }
            else
            {
                offset = (7 - firstWeekDay + 1) + 14;
            }
            return firstDate + offset;
        }
    }
     
    Step 2 - Create a contract class - ThridMondayContract (Use any name)
     
    [DataContractAttribute]
    class ThirdMondayContract
    {
        date toDate;
        [DataMemberAttribute("ToDate")]
        public date parmToDate(date _value = toDate,
                               boolean _update = true)
        {
            if (_update)
                toDate = _value;
            return toDate;
        }
    }
     
    Step 3 - Create a controller class named - ThirdMondayController (Use any name)
     
    class ThirdMondayController extends SysOperationServiceController
    {
        public static ThirdMondayController construct()
        {
            return new ThirdMondayController(
                classStr(ThirdMondayService),
                staticMethodStr(ThirdMondayService, runProcess),
                SysOperationExecutionMode::Asynchronous);
        }
        public ClassDescription caption()
        {
            return "Third Monday Batch Process";
        }
     
       public static void main(Args _args)
        {
            ThirdMondayContract   contract;
            ThirdMondayController controller;
            contract  = new ThirdMondayContract();
            controller = ThirdMondayController::construct();
            // Calculate & assign ToDate 
            contract.parmToDate(DateHelper::getThirdMonday(systemDateGet()));
            controller.parmDialogContract().parmContract(contract);
            controller.parmShowDialog(false);
            controller.startOperation();
        }
    }
     
    Step 4 - Create a Service class named - ThirdMondayService (Use any name)
     
    class ThirdMondayService
    {
        [SysEntryPointAttribute]
        public void runProcess(ThirdMondayContract _contract)
        {
            date toDate = _contract.parmToDate();
            <YOUR LOGIC HERE>
            info(strFmt("Business logic executed for date: %1", toDate));
        }
    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 659

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 465 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 304 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans