Posted on

How to Reset production order status as created in AX :

Here you go!:

void resetStatusToCreated(ProdTable _prodTable)
{
ProdMultiStatusDecrease  prodMultiStatusDecrease;
ProdParmStatusDecrease   prodParmStatusDecrease;
Args                     args = new Args();
;
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();
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *