Hi I need to do the registration for Return order lines, I provide the following link is how the final user does the registration for the Return Order Line (From step 17 to 22):
community.dynamics.com/.../return-order-in-ax-2012-r3
I need to do the same thing but by code
Some know how I can do it???
*This post is locked for comments
Hi Davut,
Thank you very much for your reply, I got the solution. below is the method I have used and it is working fine.
public void createRegisterline(SalesTable _salestable)
{
Integer lastRec = 0;
SalesId oldSalesId;
inventTrans inventTrans;
SalesFormLetter salesFormLetter;
inventTransOrigin inventTransOrigin;
TradeOrderLineRegister tradeOrderlineRegister;
autoRegistrationSBC salesReturnOrderLineRegister;
InventTransWMS_Register inventTransWMS_register;
TmpInventTransWMS TmpInventTransWMS;
ReturnDispositionCode returnDispositionCode;
Description255 errorMsg;
Args _args = new Args();
try
{
ttsBegin;
select firstOnly * from returnDispositionCode
where returnDispositionCode.DispositionAction == DispositionAction::Credit;
while select forUpdate salesLine
where _salestable.SalesId == salesLine.SalesId
&& _salestable.SalesType == SalesType::ReturnItem
{
try
{
_args.record(salesLine);
tradeOrderLineRegister = autoRegistrationSBC::construct();
tradeOrderLineRegister.parmArgs(_args);
tradeOrderLineRegister.init();
salesReturnOrderLineRegister = tradeOrderLineRegister;
salesReturnOrderLineRegister.runPreSuper();
//update returnDisposioncode
salesLine.ReturnDispositionCodeId = returnDispositionCode.DispositionCodeId;
salesLine.update();
select firstOnly crossCompany inventTrans
join RecId,InventTransId from inventTransOrigin
where inventTransOrigin.InventTransId == salesLine.InventTransId
&& inventTrans.InventTransOrigin == inventTransOrigin.RecId;
inventTransWMS_register = inventTransWMS_register::newStandard(tmpInventTransWMS);
tmpInventTransWMS.clear();
tmpInventTransWMS.initFromInventTrans(inventTrans);
tmpInventTransWMS.InventDimId = inventTrans.InventDimId;
tmpInventTransWMS.insert();
inventTransWMS_register.writeTmpInventTransWMS(tmpInventTransWMS,
inventTrans,
inventTrans.inventDim());
inventTransWMS_register.updateInvent(salesLine);
}
catch
{
continue;
}
}
ttsCommit;
}
catch
{
throw error("@SYS332911");
}
}
hello
try this code.
SalesLine salesLine = SalesLine::findRecId(00000000000);
InventTransWMS_Register inventTransWMS_register;
InventTrans inventTrans;
TmpInventTransWMS tmpInventTransWMS;
InventDim inventDim;
InventTransOriginId salesLineInventTransOriginId;
InventTransOriginId reservationLineInventTransOriginId;
SalesLine reservationLine;
ReturnDispositionCode returnDispositionCode;
SalesReturnOrderLineRegister SalesReturnOrderLineRegister;
Args args ;
;
if(salesLine)
{
if (salesLine.ReturnStatus == ReturnStatusLine::None || salesLine.ReturnStatus == ReturnStatusLine::Awaiting)
{
args = new Args();
args.record(salesLine);
SalesReturnOrderLineRegister = SalesReturnOrderLineRegister::construct();
SalesReturnOrderLineRegister.parmArgs(args);
SalesReturnOrderLineRegister.init();
SalesReturnOrderLineRegister.runPreSuper();
salesLine.ReturnDispositionCodeId = "Return";
salesLine.update();
}
inventTrans = InventTrans::findTransId(salesLine.InventTransId);
inventDim = inventTrans.inventDim();
inventTransWMS_register = inventTransWMS_register::newStandard(tmpInventTransWMS);
tmpInventTransWMS.clear();
tmpInventTransWMS.initFromInventTrans(inventTrans);
tmpInventTransWMS.InventQty = abs(5);
//tmpInventTransWMS.InventDimId = inventDim::findOrCreate(inventDim).inventDimId;
tmpInventTransWMS.InventDimId = salesLine.InventDimId;
tmpInventTransWMS.ItemId = salesLine.ItemId;
tmpInventTransWMS.LineNum = salesLine.LineNum;
//tmpInventTransWMS.insert();
inventTransWMS_register.writeTmpInventTransWMS(tmpInventTransWMS,
inventTrans,
inventTrans.inventDim());
inventTransWMS_register.updateInvent(inventTrans);
select forupdate firstonly reservationLine where reservationLine.InventRefTransId == salesLine.InventTransId;
if (reservationLine
|| salesLine.qtyMarked())
{
if ((salesLine.returnDispositionCode().DispositionAction == DispositionAction::ReplaceScrap
|| salesLine.returnDispositionCode().DispositionAction == DispositionAction::ReturnToCust
|| salesLine.returnDispositionCode().DispositionAction == DispositionAction::Scrap))
{
if (reservationLine.SalesQty == reservationLine.RemainSalesPhysical)
{
reservationLineInventTransOriginId = InventTransOriginSalesLine::findInventTransOriginId(reservationLine.DataAreaId, reservationLine.InventTransId);
salesLineInventTransOriginId = InventTransOriginSalesLine::findInventTransOriginId(salesLine.DataAreaId, salesLine.InventTransId);
InventTransOrigin::deleteMarking(salesLineInventTransOriginId, reservationLineInventTransOriginId, -salesLine.QtyOrdered);
reservationLine.delete();
}
}
else
{
throw error("@SYS332911");
}
}
}
I need to register return order through X++ code so can you please share your working code.
Can you share your code, because the code you provided is not working
Hi David, I have created a new class because the previous code has an error for the user.
Hi Eduardo
I've tried this code in a job but nothing happened.
I am curious about how can I update Qty in this code?
Thanks
I did this code to registers the Return Order Line, this is the answer to my question, I posted it, if someone has the same issue like me, you only need to set the SalesId and the ReturnDispositionCodeId:
TradeNonStockedRegisterForm tradeNonStockedRegisterForm;
TradeNonStockedRegisterTmp tradeNonStockedRegisterTmpUpdated;
SalesLine salesline;
str errorMsg = "";
System.Exception error;
try
{
while select forUpdate salesline
where salesline.SalesId == //SalesId
&& salesline.ReturnStatus == ReturnStatusLine::Awaiting
{
salesline.ReturnDispositionCodeId = //ReturnDispositionCodeId;
ttsBegin;
salesline.doUpdate();
ttsCommit;
tradeNonStockedRegisterForm = TradeNonStockedRegisterForm::newFromSalesPurchLine(salesline);
tradeNonStockedRegisterForm.populatePendingQuantityRows(tradeNonStockedRegisterTmpUpdated);
tradeNonStockedRegisterForm.insertFromTradeNonStockedRegisterTmp(tradeNonStockedRegisterTmpUpdated,
tradeNonStockedRegisterTmpUpdated,
tradeNonStockedRegisterTmpUpdated.StatusReceipt == StatusReceipt::Ordered?
tradeNonStockedRegisterTmpUpdated.Quantity : -tradeNonStockedRegisterTmpUpdated.Quantity, true);
tradeNonStockedRegisterForm.parmSelectedToRegisterNow().in(tradeNonStockedRegisterTmpUpdated.RecId);
tradeNonStockedRegisterForm.register(tradeNonStockedRegisterTmpUpdated);
}
}
catch (Exception::CLRError)
{
error = CLRInterop::getLastException();
errorMsg = error.ToString();
}
tradeNonStockedRegisterForm.populatePendingQuantityRows(tradeNonStockedRegisterTmpUpdated);
return errorMsg;
Thank you for your answer, I can create a return order but I can't generate the lines for packing slip
You can refer below link -
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,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156