Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How to order Batch Tasks

Posted on by

Hello,  We currently have a batch job that has one batch task that it runs ( it calls a batchable class), this tasks creates a shipment record.  I want to add another task to this same batch job that will then update that shipment record after it is created.  When I add a new task, it puts it on top of the existing one.  How do I know or change the order of what tasks will run first? And to have the second one run only if the first tasks succeeded?  Also, I did not create the Batch job, so it doesn't want to let me add another task, is there a way to force it to?  or will I have to delete the existing job and create a new one?

Thanks for any help!

*This post is locked for comments

  • Mark Greg Profile Picture
    Mark Greg on at
    RE: How to order Batch Tasks

    Thanks Guy, that is what I was missing and I now have it working as I intended.

    Thank you both for helping with this, I am new to AX but am starting to get the hang of it.

  • Verified answer
    Guy Terry Profile Picture
    Guy Terry 28,621 Super User 2024 Season 2 on at
    RE: How to order Batch Tasks

    Hi Mark,

    The normal way to schedule Batch tasks to run one after the other, as André hints, is to use 'Conditions'. Here, my UPS orders release after my FedEx ones:

    BatchTask.jpg

    If you are not able to manually add the task you want as a Batch task, that makes it harder. What Boris is suggesting is to use separate Batch jobs. Set the first one to run at, say, 08:00:00. If it normally takes 5 minutes to run, set the second batch job to run at 08:10:00.

  • Mark Greg Profile Picture
    Mark Greg on at
    RE: How to order Batch Tasks

    Hi Boris,

    I did as you suggested, My question is how do you set what order the tasks will run it? In a SQL Server Job you have step 1, step 2, step 3 and so on, is there something like this for a batch job's task?  I believe it is working as I intend, I'm just not understanding how to set the order of the tasks.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,280 Super User 2024 Season 2 on at
    RE: How to order Batch Tasks

    Hi Mark,

    If you have a look at e.g. the data upgrade scripts, dependencies are added (conditions on tasks) to have a certain order. I'm not sure if it would be possible to use the conditions when the job is already in executing state. If you create a new batch job, then you for sure cannot control the order. You can then only add some time before the job is executed; assuming that the initial job has been finished.

    Why don't you add all logic in the same class/method? Why do you need another task?

  • Verified answer
    BorisD Profile Picture
    BorisD 2,826 on at
    RE: How to order Batch Tasks

    My suggestion would be to just create a new batch job that will have the second task that you want to run in it and schedule it to run right after the current one is done.

    Unless you have the log on credentials for the account that created the first batch job, you will not be able to edit the task.

    I recommend for the future create all batch jobs under a service account so that you don't run into these types of issues.

    If a employee creates a batch and leaves the company and that account gets disabled, that batch job will not execute.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans