Hello friends.
Can anyone point me in the right direction on how to reserve a SalesLine item with a specific batch? I've tried numerous approaches but haven't been successful.
Here's my original example that works fine without specifying a batch. The reservation of batch is automatic, I assume FIFO is applied, and it picks up batch 1 out of the 5 available.
Here's my original example that works fine without specifying a batch. The reservation of batch is automatic, I assume FIFO is applied, and it picks up batch 1 out of the 5 available.
select inventTrans
where inventTrans.ItemId == _salesLine.ItemId
&& inventTrans.StatusReceipt == StatusReceipt::None
&& inventTrans.StatusIssue == StatusIssue::OnOrder
exists join inventTransOrigin
where inventTransOrigin.RecId == inventTrans.InventTransOrigin
&& inventTransOrigin.InventTransId == _salesLine.InventTransId;
inventmovement = inventTrans.inventmovement(true);
inventUpd_Reservation = InventUpd_Reservation::newInventDim(inventmovement, inventTrans.inventDim(), inventTrans.Qty, false);
inventUpd_Reservation.updatenow();
What I'm trying to achieve is to specifically reserve batch #3. I found some examples online, but none of them seem to work for me.
One, in particular, suggests copying inventDim and creating a new one this way (see below) but that doesn't work.
inventBatchId = "123456BATCH";
inventDim.clear();
inventDim.data(InventDim::find(_salesLine.InventDimId));
inventDim.InventBatchId = InventBatch::find(inventBatchId, _salesLine.ItemId).inventBatchId;
inventDim = InventDim::findOrCreate(inventDim);
inventMovement = InventTrans::findTransId(_salesLine.InventTransId).inventMovement(true);
inventUpd_Reservation = InventUpd_Reservation::newInventDim(inventmovement, inventDim, inventTrans.Qty, false);
inventUpd_Reservation.updatenow();
The result is I don't see reservation made in D365FO or SQL (working in onebox). Originally, I followed this article https://axfactory.wordpress.com/2015/02/28/reserve-and-remove-reservation-for-an-item-x-ax2012/ to reserve/unreserve sales line.
By the way, unreserve works just fine.
Any suggestions are appreciated as always.
Thank you, Alex