web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

How to generate a report from "Posted Sales Shipment" only if items are part of a category?

(0) ShareShare
ReportReport
Posted on by 73
Hello,
 
I'm extending the /Posted Sales Shipment/ page and created a button in order to generate contracts based on the /Item Category Code/. For hardware items, I generate a contract that would be different from software items.
 
My problem is that I don't know how to filter my /Sales Shipment Header/ table to know if there are hardware items in it and then generate the correct report.
 
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;
            }
        }
    }
}
 
Any help would be greatly appreciated!
 
Thanks in advance
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sumit Singh Profile Picture

Sumit Singh 2,179

#2
OussamaSabbouh Profile Picture

OussamaSabbouh 1,999

#3
YUN ZHU Profile Picture

YUN ZHU 1,892 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans