AX2009 Restore deleted sales table without restoring sales line
TL;DR: Restore deleted sales table without restoring sales line with X++
Problem
There are sometimes constelations where the user deletes the header of the sales order (sales table), but AX2009 will not delete the appropiate sales line entries. So we end up with open sales line entries without the header. That causes some problems when posting invoices and so on.
Solution
You could try to cancel the entries directly over AOT in the databrowser. But I went with the approach to restore the header of the salesorder from SalesTableDelete without restoring the sales lines. And after that the user can manually cancel the sales order.
AX2009 Job
static void down1_RestoreSalesTableWithoutSalesLine(Args _args)
{
SalesTableDelete ltabsalesTableDelete;
SalesTable ltabsalesTable;
;
ltabsalesTableDelete = SalesTableDelete::find('A103990087', true);
ttsbegin;
switch (ltabsalesTableDelete.Cancelled)
{
case Voided::Voided :
ltabsalesTable = conpeek(ltabsalesTableDelete.SalesTable, 1);
ltabsalesTable.insert();
ltabsalesTableDelete.delete();
break;
}
ttscommit;
}
If you enjoyed this post, you might also enjoy:
- AX2009 Cancel SalesOrder with empty SalesLine
- AX2009 Create picking list
- D365 F&O Replenishment Template Lines - set product queries by code
- AX2009 Settle Customer Open Transcation
- AX2009 Recalculate Vendor Cash Disc
- D365 F&O IOrganizationService for Dataverse
- D365 F&O Custom Work Types
MS Dynamics AX / D365 FO developer with experience in administration, developing new and adjusting the existing solutions in the Dynamics AX 2009, AX 2012, D365 FO. Ability to support all phases of implementation of project, starting with design, development, final deployment and administration. Responsible team member always looking for new challenges with experience from international projects in Austria, Germany and Switzerland. Experience in implementation of external service to MS Dynamcis AX / D365, like cash registers and warehouse automations. More about the author →