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 :
Microsoft Dynamics AX (Archived)

Setting batch status via X++

(0) ShareShare
ReportReport
Posted on by

Hello:

I'm setting up a batch job through X++ code but I would like to create the batch job in a 'withhold' state initially. Below is a snippet of the code I'm using. 

...

batInfo = rbbTask.batchInfo();
batInfo.parmCaption(sParmCaption);
batInfo.parmGroupId("");
batHeader = BatchHeader::construct();
batHeader.addUserAlerts(curUserId(),NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes);
batHeader.addTask(rbbTask);
batHeader.save();

...

Thank you!

*This post is locked for comments

I have the same question (0)
  • Rodolfo Recalde Profile Picture
    on at

    Hi DHeisman,

    I did not understand exactly what your goal....but you can create batch jobs in classes that extends RunBaseBatch. (the batch job process create automatically batch tables)

    take a look:

     >RunBaseBatch:

    https://community.dynamics.com/ax/b/alirazatechblog/archive/2014/11/12/exploring-the-batch-job-process-in-dynamics-ax-2012-r3

    >SysOperation framework:

    https://community.dynamics.com/ax/b/dynamicsaxinsightbyanas/archive/2015/04/14/ax-2012-create-a-simple-batch-job

    I Hope this helps!

    Regards,

    Rodolfo Recalde.

  • Community Member Profile Picture
    on at

    Hi Rodolfo,

    Sorry for the confusion. I have setup a class that extends the RunBaseBatch class and I'm able to create a batch job. The job runs properly and completes without issue. This is a one-time job and isn't setup for reoccurrence. Users set this batch job on an as-needed basis a custom form backed by code which programmatically creates the batch job. What I was curious about was whether I can set the status of the batch job to Withhold through code as I programmatically create the batch job. Hope that clears up the confusion.

    Thanks in advance.

  • Verified answer
    Community Member Profile Picture
    on at

    I believe you can do this.

    After batHeader.save(), I would add something like:

       select forupdate firstOnly batchJob

           where batchJob.RecId == batHeader.parmBatchHeaderId();

       if(batchJob)

       {

           batchJob.Status = BatchStatus::Hold;

           batchJob.update();

       }

    where batchJob is an instance of the BatchJob table.

  • Community Member Profile Picture
    on at

    That'll work Tom! Thanks!

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Pratik Bhosle Profile Picture

Pratik Bhosle 2

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans