We're running Microsoft Dynamics AX 2012 R3.
I've got the following code where I'm running a "Move to Bay Door" batch job followed by a "Confirm Shipment" batch job. Then, if multiple "All work" Work ID's have been selected, I want each "Move to Bay Door" to be dependent on the "Confirm Shipment" completing before the next "Move to Bay Door" runs.
//create batch header
batchHeader = BatchHeader::construct();
batchHeader.parmCaption("Move to Baydoor & Confirm Shipment");
while(whsWorkTable)
{
bayDoorBatchTask = UT_AP_WHSWorkFinalizeComplete::construct(whsWorkTable.WorkId);
//add the baydoor batch tasks to a 'set' for processing later
setBayDoors.add(bayDoorBatchTask);
//add the batch tasks to the batch header
batchInfo = bayDoorBatchTask.batchInfo();
batchInfo.parmCaption(strFmt("Move to Bay Door for WorkId %1",whsWorkTable.WorkId));
batchInfo.parmGroupId("AOS2");
batchHeader.addTask(bayDoorBatchTask);
batchHeader.addRuntimeTask(bayDoorBatchTask,BatchHeader::getCurrentBatchTask().RecId);
confirmShipBatchTask = UT_AP_WHSWorkShipConfirm::construct(whsWorkTable.WorkId, true, false);
//add the batch tasks to the batch header
batchInfo = confirmShipBatchTask.batchInfo();
batchInfo.parmCaption(strFmt("Confirm Shipment for WorkId %1",whsWorkTable.WorkId));
batchInfo.parmGroupId("AOS2");
batchHeader.addTask(confirmShipBatchTask);
batchHeader.addRuntimeTask(confirmShipBatchTask,BatchHeader::getCurrentBatchTask().RecId);
//define a dependency between the Move to Bay Door and the Confirm Shipment tasks
batchHeader.addDependency(confirmShipBatchTask, bayDoorBatchTask, BatchDependencyStatus::Finished);
whsWorkTable = multiSelectionHelper.getNext();
}
// Create dependencies between bayDoor batches
sBayDoors = setBayDoors.getEnumerator();
sBayDoors.movenext();
bayDoorBatchTask = sBayDoors.current(); //1st bay door task
while (sBayDoors.movenext())
{
bayDoorBatchTask2 = sBayDoors.current(); //2nd bay door task
// Now define a dependency between the Move to Bay Doors
batchHeader.addDependency(bayDoorBatchTask2, bayDoorBatchTask, BatchDependencyStatus::FinishedOrError);
bayDoorBatchTask = bayDoorBatchTask2; //Assign 2nd task to 1st task and repeat
}
//save the batch
batchHeader.save();
The Results:
|
Ended |
Move to Bay Door for WorkId 0746820 |
2/7/2019 |
01:18:03 pm |
2/7/2019 |
01:20:17 pm |
No Dependencies |
|
Ended |
Confirm Shipment for WorkId 0746820 |
2/7/2019 |
01:20:17 pm |
2/7/2019 |
01:23:57 pm |
Dependencies |
|
Ended |
Move to Bay Door for WorkId 0746824 |
2/7/2019 |
01:20:17 pm |
2/7/2019 |
01:28:23 pm |
Dependencies |
|
Ended |
Confirm Shipment for WorkId 0746824 |
2/7/2019 |
01:28:25 pm |
2/7/2019 |
01:34:21 pm |
Dependencies |
So my 2nd "Move to Bay Door" started before my 1st "Confirm Shipment" ended. My dependency between the "Move to Bay Door" and the "Confirm Shipments" seems to be working just fine, but my dependency between "Move to Bay Doors" doesn't seem quite right.
*This post is locked for comments
I have the same question (0)

Report
All responses (
Answers (