pageextension 50125 PostedSalesShipmentExt extends /Posted Sales Shipment/
{
actions
{
addlast(processing)
{
action(/Generate Contracts/)
{
ApplicationArea = Basic, Suite;
Promoted = true;
PromotedCategory = Category4;
Image = Export;
trigger OnAction()
var
XmlParameters: Text;
FileMgt: Codeunit /File Management/;
Filename: Text;
TempBlob_lRec: Codeunit /Temp Blob/;
BlobOutStream: OutStream;
RecRef: RecordRef;
SalesShptHeader: Record /Sales Shipment Header/;
SalesShipmentLine: Record /Sales Shipment Line/;
RecLineRef: RecordRef;
CountLines: Integer;
begin
SalesShptHeader.Reset();
SalesShptHeader.SetRange(/No./, Rec./No./);
SalesShptHeader.FindFirst();
SalesShipmentLine.Reset();
SalesShipmentLine.SetRange(/No./, Rec./No./);
SalesShipmentLine.SetFilter(/Item Category Code/, '1.0-COTS-HARDWARE');
RecLineRef.GetTable(SalesShipmentLine);
CountLines := RecLineRef.Count();
RecRef.GetTable(SalesShptHeader);
if (RecRef.Count() > 0) then begin
XmlParameters := Report.RunRequestPage(Report::PostedSalesShptContractsReport);
// XmlParameters := '<?xml version=/1.0/ standalone=/yes/?><ReportParameters name=/PostedSalesShptContractsReport/ id=/50125/><DataItems><DataItem name=/Header/>VERSION(1) SORTING(Field3)</DataItem><DataItem name=/Line/>VERSION(1) SORTING(Field3,Field4)</DataItem><DataItem name=/ItemTrackingLine/>VERSION(1) SORTING(Field1)</DataItem></DataItems></ReportParameters>';
TempBlob_lRec.CreateOutStream(BlobOutStream, TEXTENCODING::UTF8);
report.SaveAs(Report::PostedSalesShptContractsReport, XmlParameters, REPORTFORMAT::Pdf, BlobOutStream, RecRef);
Filename := Format(Rec./No./) + '.pdf';
FileMgt.BLOBExport(TempBlob_lRec, Filename, TRUE);
end;
end;
}
}
}
}