Unregister inventory with code X++

Hi all.

Can someone explain to me how can i unregister quantity for line in PO (Purchase Order) with code. It is urgent so i will be grateful for any answers.

Hi Tyto,

Please see the Clicked method of the form InventTransRegister /Design/Group:RegisterNowGroup/ActionPane:ActionPaneRegisterNow/ActionPaneTab:ActionPaneTabRegisterNow/Button Group:RegistrationActionsGroup/Button:ctrlUpdateButton

Hi Ishak. Thank you for you reply. Do you think that all the process i being done in the clicked method(). I have seen it and there is pretty big piece of code :slight_smile:

Hi everyone. I have found my solution. The key is to use the InventTransWMS_register class. Here is the job with whom I have tested it, and it works.

static void testUnregistration(Args _args)

{

PurchTable purchTable;

InventTrans inventTrans;

InventTransOrigin inventTransOrigin;

PurchLine purchLine;

InventDim inventDim;

TmpInventTransWMS tmpInventTransWMS;

InventTransWMS_register inventTransWMS_register = inventTransWMS_register::newStandard(tmpInventTransWMS);

while select purchLine where purchLine.PurchId == this.PurchId

{

select inventTransOrigin

where inventTransOrigin.ReferenceId == purchLine.PurchId

&& inventTransOrigin.ItemId == purchLine.ItemId;

while select inventTrans

where inventTrans.InventTransOrigin == inventTransOrigin.RecId

{

select inventDim where inventDim.inventDimId == inventTrans.inventDimId;

if (inventTrans.StatusReceipt == StatusReceipt::Registered)

{

inventTransWMS_register.createFromInventTrans(inventTrans, inventDim);

inventTransWMS_register.updateInvent(purchLine);

}

}

}

}

P.S. Thanks to Ishak for his reply.