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

Notifications

Announcements

No record found.

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!
I have the same question (0)
  • Verified answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,284 Super User 2025 Season 2 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,284 Super User 2025 Season 2 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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,917

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,161 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,025 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans