Skip to main content
Answered

Make custom report that uses the record you're currently viewing

editSubscribe (0) ShareShare
ReportReport
Posted on by 75

Good afternoon, I'm learning Business Central development for our company so we can customize it for our needs. I'm working on setting up a custom report that you can generate that uses the data on the record you're currently viewing (so if you're looking at a Production Order, the report's dataset is of that record). The only information I've found online doesn't specify how to have the dataset use the record that's currently open. When you run the report, no matter what you have open, it just uses the first record from the table. Obviously that's not very useful.

Below is the code I'm working with right now.

pageextension 50003 MakeCocOnOpen extends "Released Production Order"
{
    trigger OnOpenPage();
    begin
        report.Run(Report::CertificateOfConformance);
    end;
}

report 50003 CertificateOfConformance
{
    DefaultLayout = RDLC;
    RDLCLayout = 'MyRDLReport.rdl';
    
    dataset
    {
        dataitem("Production Order"; "Production Order")
        {
            column(Description; Description){}
            column(No_; "No."){}
            column(Source_No_; "Source No."){}
        }
    }
}

If anyone has any advice for how to do that or could point me to some resources, that would be awesome. Thank you!