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 :
Business Central forum

Custom sales report linking lot number sold to customer to the vendor that it was purchased from

(0) ShareShare
ReportReport
Posted on by 135

I am working on a custom report based on the sales invoice tables that shows the lot number, the cost from the lot and the vendor from which the items were purchased. I am having trouble pulling the vendor information in to the dataset. Has anyone done this before or can anyone help me with the code? My code is below. Side note: the result in report builder returns multiple rows for each line on the sales invoice, and i am curious to know if there is a better way to write this so that I get 1 row in my result for every line on the sales invoice.

report 50111 "Bulk Invoice Report_dev"
{
UsageCategory = Administration;
ApplicationArea = All;
DefaultLayout = RDLC;
RDLCLayout = 'rdl_layouts\Bulk Invoice Report_DEV.rdl';
dataset
{


dataitem("Sales Invoice Header"; "Sales Invoice Header")
{
RequestFilterFields = "No.", "Document Date";
column(External_Document_No_; "External Document No.")
{
}
column(New_Basis; "New Basis")
{
}
column(No_; "No.")
{
}
column(Payment_Terms_Code; "Payment Terms Code")
{
}
column(Sell_to_Customer_Name; "Sell-to Customer Name")
{
}
column(Document_Date; "Document Date")
{
}
dataitem("Sales Invoice Line"; "Sales Invoice Line")
{
DataItemLinkReference = "Sales Invoice Header";
DataItemLink = "Document No." = field ("No.");
column(Document_No_; "Document No.")
{
}
column(OriginState; OriginState)
{
}
column(Bill_to_Customer_No_; "Bill-to Customer No.")
{
}
column(Location_Code; "Location Code")
{
}
column(Item_No_; "No.")
{
}
column(Quantity; Quantity)
{
}
column(Package_Tracking_No_; "Package Tracking No.")
{
}
column(Unit_Cost; "Unit Cost")
{
DecimalPlaces = 4 : 4;
}
column(Unit_Price; "Unit Price")
{
DecimalPlaces = 4 : 4;
}
dataitem(Location; Location)
{
DataItemLinkReference = "Sales Invoice Line";
DataItemLink = "Code" = field ("Location Code");
column(LocationName_; "Name")
{
}
column(Code; Code)
{
}

}
dataitem("Sales Shipment Line"; "Sales Shipment Line")
{
DataItemLinkReference = "Sales Invoice Line";
DataItemLink = "Order No." = field ("Order No."), "No." = field ("No.");
column(shipment_Document_No_; "Document No.")
{
}
dataitem("Item Ledger Entry"; "Item Ledger Entry")
{
DataItemLinkReference = "Sales Shipment Line";
DataItemLink = "Document No." = field ("Document No.");
column(Lot_No_; "Lot No.")
{

}
column(Item_No_Ledger; "Item No.")
{

}
column(Document_Line_No_; "Document Line No.")
{

}
column(Document_No_Ledger; "Document No.")
{

}
dataitem("Item Ledger Entry_rct"; "Item Ledger Entry")
{
DataItemLinkReference = "Item Ledger Entry";
DataItemLink = "Lot No." = field ("Lot No.");//, "Item No." = field ("Item No.");
DataItemTableView = where ("Document Type" = const ("Purchase Receipt"));
dataitem("Purch. Rcpt. Line"; "Purch. Rcpt. Line")
{
DataItemLinkReference = "Item Ledger Entry_rct";
dataitemlink = "Document No." = field ("Document No."),
"Line No." = field ("Order Line No.");
column(Item_Rcpt__Entry_No_; "Item Rcpt. Entry No.")
{
}
column(Rcpt_Line_No_; "Line No.")
{
}
column(Buy_from_Vendor_No_; "Buy-from Vendor No.")
{
}
dataitem("Purch. Rcpt. Header"; "Purch. Rcpt. Header")
{
DataItemLinkReference = "Purch. Rcpt. Line";
dataitemlink = "No." = field ("Document No.");
column(Buy_from_Vendor_Name; "Buy-from Vendor Name")
{

}
}
}
}
}
}
}
}
}
}


I have the same question (0)
  • Syuhadah Profile Picture
    15 on at
    Hello!
     
    Can I check if you are able to display the Lot No. in your report? Because currently I have a task where I need to display Lot No. in Work Order report. So I'm trying to use your code but somehow the Lot No. is not displayed. 
     
    Thanks in advance,
     
    Syu
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    21,573 Super User 2026 Season 1 on at

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans