Thursday, March 12, 2026

How to Block Manual Execution of a Running Recurring Batch Job in D365FO (X++)

 public boolean validate()

{

    boolean ret = true;

    BatchJob batchJob;

    Batch batch;


    select firstOnly batchJob

    join batch

    where batch.BatchJobId == batchJob.RecId

       && batch.ClassNumber == className2Id(classStr(Sysopertaioncontrollertest))

       && (batchJob.Status == BatchStatus::Waiting ||

           batchJob.Status == BatchStatus::Executing);

    if (batchJob)

    {

        error("This batch job is already running. Please wait for it to finish.");

        ret = false;

    }

    return ret;

}

No comments:

Post a Comment