Monday, 6 April 2015

Restore deleted Sales order in AX 2012


How to Restore deleted sales order or purchase order Ax 2012 ?


If the parameter 'Mark order as voided' is enabled in the Accounts receivable parameters, you can find the deleted order in the form "Voided sales orders" that can be found under Sales and marketing/Inquiries/History/Voided sales orders. 

In fact the history tables contains sent Confirmations, Packing slips and Invoices.

Sales order restoration:

static void restoreDeletedSO(Args _args)
{
SalesTableDelete    salesTableDelete;
SalesLineDelete     salesLineDelete;
SalesTable          salesTable;
SalesLine           salesLine;
;
SalesTableDelete = SalesTableDelete::find(‘00450_036′, true);
ttsbegin;
switch (salesTableDelete.Cancelled)
{
case Voided::Voided :
salesTable  = conpeek(salesTableDelete.SalesTable, 1);
salesTable.insert();
while select forupdate salesLineDelete where salesLineDelete.SalesId == salesTableDelete.SalesId
{
salesLine = conpeek(salesLineDelete.SalesLine, 1);
salesLine.insert();
}
salesTableDelete.delete();
break;
case Voided::linesVoided :
while select forupdate salesLineDelete where salesLineDelete.SalesId == salesTableDelete.SalesId
{
salesLine = conpeek(salesLineDelete.SalesLine, 1);
salesLine.insert();
salesLineDelete.delete();
}
salesTableDelete.delete();
break;
}
ttscommit;
}

Thanks & Regards
Sindhu

5 comments:

  1. It doesnt work in ax2012 the code gives an error on line 1 and 3. First of all there is a parameter missing you have to turn on to record your deletes in ax2012.

    ReplyDelete
  2. Was it intentional to leave the SalesTableDelete deletion out of the While statement for the Voided Case?

    ReplyDelete
  3. Halo,I'm Helena Julio from Ecuador,I want to talk good about Le_Meridian Funding Service on this topic.Le_Meridian Funding Service gives me financial support when all bank in my city turned down my request to grant me a loan of 500,000.00 USD, I tried all i could to get a loan from my banks here in Ecuador but they all turned me down because my credit was low but with god grace I came to know about Le_Meridian so I decided to give a try to apply for the loan. with God willing they grant me  loan of 500,000.00 USD the loan request that my banks here in Ecuador has turned me down for, it was really awesome doing business with them and my business is going well now. Here is Le_Meridian Funding Investment Email/WhatsApp Contact if you wish to apply loan from them.Email:lfdsloans@lemeridianfds.com / lfdsloans@outlook.comWhatsApp Contact:+1-989-394-3740.

    ReplyDelete