AX 2012 | D365: Post Packing Slip using X++

static void postPackingSlip(Args _args)
{
SalesFormLetter salesFormLetter;
SalesTable salesTable;
SalesId salesId = ‘SO00001’;
System.Exception error;
str strError;
CustPackingSlipJour custPackingSlipJour;
;

ttsBegin;
try
{
salesTable = SalesTable::find(salesId);

if (salesTable && salesTable.SalesStatus == SalesStatus::Backorder)
{
salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip);
salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::PackingSlip, AccountOrder::None, NoYes::No, NoYes::No, NoYes::No);

if (salesFormLetter.parmJournalRecord().TableId == tableNum(custPackingSlipJour))
{
custPackingSlipJour = salesFormLetter.parmJournalRecord();
info(strFmt(‘New Packing Slip #:%1 successfully created for Sales Order #:%2’, custPackingSlipJour.PackingSlipId, custPackingSlipJour.SalesId));
}
}
else
{
info(strFmt(‘%1 does not exsists or null in the system, please try again!’, salesId));
}

}
catch (Exception::CLRError)
{
error = CLRInterop::getLastException();
strError = error.ToString();

info(strfmt(‘%1’, strError));
info(strFmt(‘%1 failed to delivered, please try again!’, salesId));
}
ttscommit;
}

Leave Comment

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