Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Setting batch status via X++

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Setting batch status via X++

    That'll work Tom! Thanks!

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee 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
    Community Member Microsoft Employee 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.

  • 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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans