Tag Archives: How to post packing slip using x++

AX 2012: Post Packing Slip using X++

AX 2012: 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;
}

AX 2012: Posting Packing Slip using X++

static void JobPostPackingSlip(Args _args)
{
SalesFormLetter_PackingSlip     salesFormLetter_PackingSlip;

SalesTable                      salesTable;
CustPackingSlipJour             custPackingSlipJour;

;

ttsBegin;
salesTable = SalesTable::find(‘SO00000001’);
salesFormLetter_PackingSlip = SalesFormLetter::construct(DocumentStatus::PackingSlip);
salesFormLetter_PackingSlip.showQueryForm(false);
salesFormLetter_PackingSlip.update(salesTable,
systemDateGet(),
SalesUpdate::DeliverNow,
AccountOrder::None,
false,
false);
ttsCommit;

if (CustPackingSlipJour::exist(‘SO00000001’))
info(strFmt(‘Sales Order successfully delivered!’));
else
info(strFmt(‘Sales Order failed to deliver!’));
}