web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Batch job classes to skip processing on criteria

(0) ShareShare
ReportReport
Posted on by 6,472
Hello,
Which class / method would be the best to use as COC and to place the custom code in both runBase and sysoperational framework?
Our goal is to skip batch jobs from executing on some week days if the week day is a public holiday.
We already have a custom table for holidays.
I'm searching for some general place, where I can apply my logic.
I can easily do it for the specific batch jobs, but I want the logic to be applied for all the batch jobs, which will have a setup to custom holiday table.
Thanks
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    236,471 Most Valuable Professional on at
    Batch job classes to skip processing on criteria
    Please tell us more about the expected behaviour.
     
    Do you want the batch to run and end immediately if the condition is met? Or do you want to actually prevent scheduling on those days (either manually or by recurrence)?
     
    Are you 100% sure that you want it for all batches, including system batches, integration, email distributor etc.? It doesn't sound like a good idea to me (and it's actually not possible with some system batches). On the contrary, public holidays may be a good time to run some batches that would otherwise slow down the system for users.
  • Johnny Profile Picture
    6,472 on at
    Batch job classes to skip processing on criteria
    Hi Martin,
    so.. we have added relation from BatchJob table to Holidays table. We also have HolidayLines under holiday table.
    When the batch job is set to run in reccurance, we want to check if the Holidays is selected on the batch. If selected, we would like the batch job to end immediatelly.
    The holidays setup will be set only to custom batch jobs, but it is still quit a lot to write code in each batch class separatelly.
     
    Initially we have developed it just for one batch job and below is the code snippet from the method of that batch job class.
    Basically this is what I want to do, but in all "custom batch job" cases.
    BatchHeader batchHeader = BatchHeader::getCurrentBatchHeader();
    if (batchHeader)
    {
        HolidayLine holidayLine = BatchJobHolidaySetupHelper::holidayToday(batchHeader.parmBatchHeaderId());
        if (holidayLine)
        {
            throw warning(strFmt("@XXX", holidayLine.HolidayDate, holidayLine.Name));
        }
    }
     
  • Suggested answer
    Martin Dráb Profile Picture
    236,471 Most Valuable Professional on at
    Batch job classes to skip processing on criteria
    Then consider doing it in BatchRun::runJobStatic().

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,964

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 823 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 564 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans