I added a cancel order button in sales order form, when we click this button sales order will get canceled but here I need to restrict that if any of the lines is delivered it will not allow to cancel the order…
My coding on Clicked method is:
void clicked()
{
Dialogbutton db1,db2,db3,db4;
;
if(SalesTable.SalesStatus==SalesStatus::Backorder)
{
db1 = box::yesNo("Do you want to Cancel PO?", dialogButton::No, "Cancel Order");
if (db1 == dialogButton::Yes)
{
db2 = box::yesNo("This Will Cancel all the PO, no further activities is possible. Do you want to continue?", dialogButton::No, "Cancel Order Confirmation");
if(db2 == dialogButton::Yes)
{
SalesTable.SalesStatus=SalesStatus::Canceled;
SalesTable.update();
SalesTable_ds.refresh();
info(strfmt("%1",SalesTable.SalesId));
}
}
}
else if( SalesTable.SalesStatus==SalesStatus::Canceled)
{
db3=box::yesNo("Do you want to Open PO again?",dialogButton::Yes,"Revoke Cancel");
if (db3 == dialogButton::Yes)
{
db4= box::yesNo("This Will Open all the PO again. Do you want to continue?", dialogButton::Yes, "Open Order Confirmation");
if(db4 == dialogButton::Yes)
{
SalesTable.SalesStatus=SalesStatus::Backorder;
SalesTable.update();
SalesTable_ds.refresh();
info(strfmt("%1",SalesTable.SalesId));
}
}
}
else
{
info( "Process canceled");
}
}
How could I change my coding there to restrict the button from canceling the order?
Coming back to ur question, u can place a condition and select salesline for the salestable using salesid as the reference with delivered status.
REGARDING THE LOGIC FOR CANCELLING sales order, i don’t think by just updating it works
if(SalesTable.SalesStatus==SalesStatus::Backorder)
{
select … /// finds a record with delivered status
if(salesline.recid)
{
info( “Process canceled as the selected SO is in delivered state”); // place ur own infolog
}
else
{
db1 = box::yesNo(“Do you want to Cancel PO?”, dialogButton::No, “Cancel Order”);
if (db1 == dialogButton::Yes)
{
db2 = box::yesNo(“This Will Cancel all the PO, no further activities is possible. Do you want to continue?”,
dialogButton::No, “Cancel Order Confirmation”);
if(db2 == dialogButton::Yes)
{
SalesTable.SalesStatus=SalesStatus::Canceled;
SalesTable.update();
SalesTable_ds.refresh();
info(strfmt("%1",SalesTable.SalesId));
}
}
}
Lines status will get updated as delivered when all the quantities got delivered, but here even in line one quantitiy got delivered it shouldn’t allow to cancel the order…
There is already a function to cancel the entire sales order in AX 2012, i don’t remember if it existed in AX 2009.
If you have AX 2012 , check \Classes\SalesUpdateRemain. You can use the similar logic.
Functionality to cancel the sales orders are exist in AX 2009.
Sales Order Details → Functions Button(footer) → Delivery Remainder → It will opens form update remaining quantity → Click OK button.