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 :
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)
  • Community Member Profile Picture
    on at
    RE: Setting batch status via X++

    That'll work Tom! Thanks!

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Setting batch status via X++

    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
    RE: Setting batch status via X++

    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.

  • Rodolfo Recalde Profile Picture
    on at
    RE: Setting batch status via X++

    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.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Mea_ Profile Picture

Mea_ 4

#3
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans