Hi All
I have added a button with following code to post packing slip for all sales order lines (SalesLine) with quantity in 'Delivery now' field.
void clicked()
{
CustPackingSlipJour custPackingSlipJour;
SalesFormLetter salesFormLetter;
System.Exception error;
String255 strError;
ttsBegin;
try
{
if (SalesTable.SalesStatus == SalesStatus::BackOrder)
{
salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip);
salesFormLetter.update(
SalesTable,
systemDateGet(),
SalesUpdate::DeliverNow,
AccountOrder::None,
NoYes::No,
NoYes::Yes,
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
{
warning('Error posting packing slip, try again');
}
}
else
{
warning('Order status must be \'Open order\' before posting packing slip');
}
}
catch (Exception::CLRError)
{
error = CLRInterop::getLastException();
strError = error.ToString();
info(strfmt('%1', strError));
info(strFmt('%1 failed to delivered, please try again!', SalesTable.SalesId));
}
ttsCommit;
}
I have added all methods of 'SalesFormLetter' and 'SalesFormLetter_PackingSlip' classes in users permission but still packing slip is not getting posted when the user is clicking on the button. .
Moreover, the user can post packing slip through 'Packing slip' button available in 'Pick and pack' tab.

Can anybody let me know possible solution for this issue.
Thanks in advance.
Haroon