How to cancel a product receipt for a Consignment Replenishment Order in Dynamics 365 Finance and Operations (D365FO) using X++
How to cancel a product receipt for a Consignment Replenishment Order in Dynamics 365 Finance and Operations (D365FO) using X++
Copy Paste from ChatGPT. even replenishment order journal records not going to vendPackingSlipJour and trans.
Hi Javid,
To cancel a product receipt for a Consignment Replenishment Order in Dynamics 365 Finance and Operations (D365FO) using X++, you can follow these steps:
Open the development environment (Visual Studio).
Create a new job or open an existing job.
Connect to the D365FO environment and select the appropriate company.
Write the X++ code to cancel the product receipt. Here's an example:
static void CancelProductReceipt(Args _args)
{
InventTrans inventTrans;
InventTransRefType inventTransRefType;
VendPackingSlipJour vendPackingSlipJour;
VendPackingSlipLine vendPackingSlipLine;
InventTransId inventTransId = '<your_inventtrans_id>';
// Retrieve the inventory transaction for the consignment replenishment order
select inventTrans
where inventTrans.TransRefId == inventTransId &&
inventTrans.RefTransRefId != '';
while (inventTrans)
{
// Retrieve the reference type for the inventory transaction
inventTransRefType = inventTrans.getTransRefType();
// Check if the reference type is a packing slip
if (inventTransRefType == InventTransRefType::PackingSlip)
{
// Retrieve the packing slip journal based on the reference id
vendPackingSlipJour = VendPackingSlipJour::find(inventTrans.RefTransRefId);
// Cancel the packing slip journal
if (vendPackingSlipJour)
{
vendPackingSlipJour.packingSlipStatus = VendPackingSlipStatus::Canceled;
vendPackingSlipJour.update();
// Retrieve the packing slip lines and cancel them
while select forUpdate vendPackingSlipLine
where vendPackingSlipLine.PackingSlipId == vendPackingSlipJour.PackingSlipId
{
vendPackingSlipLine.LineStatus = VendPackingSlipLineStatus::Canceled;
vendPackingSlipLine.update();
}
}
}
// Move to the next inventory transaction
inventTrans = inventTrans.next();
}
info("Product receipt canceled successfully.");
}
Replace <your_inventtrans_id> with the actual InventTransId of the consignment replenishment order you want to cancel.
Compile and run the job.
The code will search for the specified consignment replenishment order's inventory transactions and check if they reference a packing slip. If a packing slip is found, it will be canceled, along with its associated packing slip lines.
After running the job, you should see a confirmation message stating that the product receipt was canceled successfully.
Please note that this code is a basic example and may need modification based on your specific requirements and customization in your D365FO environment.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,269 Super User 2024 Season 2
Martin Dráb 230,198 Most Valuable Professional
nmaenpaa 101,156