Hi Everyone,
I need urgent help.
I want to reset the Production order through X++ to Created Stage.
I have written below job code in AX2012 R3 which was written on multiple blogs.
But when I try to run job facing below error,
"The status cannot be reset from Scheduled to Created on production PRD/18-19/003221 because of the parameter setup."
"Update has been canceled."
Can anybody suggest some solution on this?
Below is the logic written in Job
static void resetProductionOrder_TestJob(Args _args)
{
ProdId _prodId = "PRD/18-19/003221";
ProdMultiStatusDecrease prodMultiStatusDecrease;
ProdParmStatusDecrease prodParmStatusDecrease;
ProdTable prodTable;
Args args = new Args();
;
Try
{
ttsbegin;
prodTable = ProdTable::find(_prodId,true);
if (prodTable.ProdStatus > prodStatus::Created)
{
args.record(prodTable);
select prodParmStatusDecrease where prodParmStatusDecrease.ProdId == prodTable.ProdId;
if (!prodParmStatusDecrease.RecId)
{
prodParmStatusDecrease.clear();
prodParmStatusDecrease.initFromProdTable(prodTable);
prodParmStatusDecrease.WantedStatus = ProdStatus::Created;
prodParmStatusDecrease.ParmId = NumberSeq::newGetNum(CompanyInfo::numRefParmId()).num();
prodParmStatusDecrease.insert();
}
prodMultiStatusDecrease = prodMultiStatusDecrease::construct(args);
prodMultiStatusDecrease.initParmBuffer(prodParmStatusDecrease);
prodMultiStatusDecrease.parmId(prodParmStatusDecrease.ParmId);
prodMultiStatusDecrease.run();
}
ttsCommit;
info("Done");
}
Catch (Exception::error)
{
checkFailed(strFmt("Delete of Production order %1 is failed.", _prodId));
}
}
.
Thank you in advance