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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Document Report for Selected Sales Order

(0) ShareShare
ReportReport
Posted on by 10

I have created a document report in Visual Studio Code. The report pulls data from the Sales Header table, as well as the Sales Lines subform and the Locations table, which are linked through the customer number and location code respectively.

The form is a Bill of Lading, and I have created the layout in Word.

The report runs off a link I have added to the Sales Order page (page 42):

actions
    {
        addlast(reporting)
        {
            action(WGP_BOL_Report)
            {
                ApplicationArea = All;
                Caption = 'Bill of Lading';
                trigger OnAction();
                begin
                    Report.Run(Report::WGP_BOL_Report);
                end;
            }
        }
    }
 
I would like it to pull the fields from the currently selected Sales Order, and use the customer number in the currently selected Sales Order and the location code in the currently selected sales order to populate the Bill of Lading form. However, it is currently pulling the data from the first record in the Sales Order List.
TIA!
  • Verified answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,306 Super User 2026 Season 1 on at

    You need to use Variable.

    Example:

    trigger OnAction()

    var

     SalesHeader:Record "Sales Header";

     WGPBOLReport:Report "WGP_BOL_Report";

    begin

     SalesHeader.SetRange("Sell-to Customer No.",Rec."Sell-to Customer No.");

     SalesHeader.SetRange("Location Code",Rec."Location Code");

     WGPBOLReport.SetTableView(SalesHeader);

     WGPBOLReport.Run();

    end;

  • david_f Profile Picture
    10 on at

    Thank you so much Teddy!

    I would like to ask a follow-up question. I am new to the community, so if this is not the proper way to ask a follow-up question, please advise.

    In the Sales Header table, there is an Address field and an Address2 field. Often the Address2 field is empty. Is there a way not to print a blank line for an empty field in the report?

    Thank you again!

  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,306 Super User 2026 Season 1 on at

    I am guessing you are talking about the header of the report ?

    You can hide and show the field by using the visibility properties. However, you only hide it. The gaps / spaces is still be there. You can't shrunk the space.

  • david_f Profile Picture
    10 on at

    Thanks again Teddy!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 664 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 446 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 282 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans