This post is machine-translated. The original post in german language can be found here.
These post applies to following version:
Dynamics AX 2012
Dynamics AX 2012
Hi! We have a scenario where we by code create mutiple batch tasks at runtime. - We have a "main"-task that in each batch run gathers data to be processed. - The case is that we want to have one batchtask per a ProjectId. But after the batch is finished all the individual ProjectId-tasks are still there in the batch job. The next time the "main"-task is fired there should be no batch tasks in the batchjob. Because there should be a new set of ProjectId-batchtasks created based on what data that exist in the database. The same batchjob is used over and over again due to a scheduled recurrency. What is the proper way to "clean up" the batch task list before the new batchrun occur? |
Hi! We have a scenario where we by code create mutiple batch tasks at runtime. - We have a "main"-task that in each batch run gathers data to be processed. - The case is that we want to have one batchtask per a ProjectId. But after the batch is finished all the individual ProjectId-tasks are still there in the batch job. The next time the "main"-task is fired there should be no batch tasks in the batchjob. Because there should be a new set of ProjectId-batchtasks created based on what data that exist in the database. The same batchjob is used over and over again due to a scheduled recurrency. What is the proper way to "clean up" the batch task list before the new batchrun occur? |
|
|
|
|
|
|
|
The code snippets below show how to create batch jobs using the BatchHeader class.
Examples for a RunBaseBatch construct
If you want to make sure that the individual tasks are processed in a certain order or between dependencies, you can do this as follows:
Of course you can also set up warnings...
...or set a planned start time:
And of course you can also control the reccurence:
Example for a SysOperation-Construct
Everything that is possible for a RunBaseBatch build is also possible for the SysOeration framework. Here you only have to take care to set the SysOperationExecutionMode correctly:
Combined example
And of course it is also possible to combine RunBaseBatch and SysOperation in one batch job: