Hey community,
I have gone through a similar case (https://community.dynamics.com/business/f/dynamics-365-business-central-forum/457532/display-line-comments-on-proforma-invoice) but the solution is not working in my case. I have created an entirely new file copying the content of the original report layout and removing predataitem trigger but it is still not working. I'm not getting comments line. Kindly help
You can extend a custom report the same way that you can extend a standard report.
No problem ZHU. Thank you. One more thing I want to ask can we extend a custom report?
Hi, sorry, it's more complicated, it's customization. You need to create an Extension. I suggest you contact your developers.
Some learning source:
Collection: Extend Business Central
Hope this helps.
Thanks.
ZHU
Thank ZHU, but can you show me how to upload it as Proforma Invoice.
Hi, sorry for misleading you, the link does not open before, I thought there was a problem, but it turns out that I need to remove the brackets
I understand now, you want to print the Comments in the line, not in the Comments feature.
I tested it and there are actually two places you need to modify. (Maybe it have other problem, I haven't tested it in detail)
OK.
Source code: I did not make any changes to the Layout file.
report 50111 "ZY Sales Pro Forma Inv" { DefaultLayout = RDLC; RDLCLayout = './ZYStandardSalesProFormaInv.rdlc'; Caption = 'ZY Pro Forma Invoice'; dataset { dataitem(Header; "Sales Header") { DataItemTableView = SORTING("Document Type", "No."); RequestFilterFields = "No.", "Sell-to Customer No.", "No. Printed"; RequestFilterHeading = 'Pro Forma Invoice'; column(DocumentDate; Format("Document Date", 0, 4)) { } column(CompanyPicture; CompanyInformation.Picture) { } column(CompanyEMail; CompanyInformation."E-Mail") { } column(CompanyHomePage; CompanyInformation."Home Page") { } column(CompanyPhoneNo; CompanyInformation."Phone No.") { } column(CompanyVATRegNo; CompanyInformation.GetVATRegistrationNumber()) { } column(CompanyAddress1; CompanyAddress[1]) { } column(CompanyAddress2; CompanyAddress[2]) { } column(CompanyAddress3; CompanyAddress[3]) { } column(CompanyAddress4; CompanyAddress[4]) { } column(CompanyAddress5; CompanyAddress[5]) { } column(CompanyAddress6; CompanyAddress[6]) { } column(CustomerAddress1; CustomerAddress[1]) { } column(CustomerAddress2; CustomerAddress[2]) { } column(CustomerAddress3; CustomerAddress[3]) { } column(CustomerAddress4; CustomerAddress[4]) { } column(CustomerAddress5; CustomerAddress[5]) { } column(CustomerAddress6; CustomerAddress[6]) { } column(CustomerAddress7; CustomerAddress[7]) { } column(CustomerAddress8; CustomerAddress[8]) { } column(SellToContactPhoneNoLbl; SellToContactPhoneNoLbl) { } column(SellToContactMobilePhoneNoLbl; SellToContactMobilePhoneNoLbl) { } column(SellToContactEmailLbl; SellToContactEmailLbl) { } column(BillToContactPhoneNoLbl; BillToContactPhoneNoLbl) { } column(BillToContactMobilePhoneNoLbl; BillToContactMobilePhoneNoLbl) { } column(BillToContactEmailLbl; BillToContactEmailLbl) { } column(SellToContactPhoneNo; SellToContact."Phone No.") { } column(SellToContactMobilePhoneNo; SellToContact."Mobile Phone No.") { } column(SellToContactEmail; SellToContact."E-Mail") { } column(BillToContactPhoneNo; BillToContact."Phone No.") { } column(BillToContactMobilePhoneNo; BillToContact."Mobile Phone No.") { } column(BillToContactEmail; BillToContact."E-Mail") { } column(YourReference; "Your Reference") { } column(ExternalDocumentNo; "External Document No.") { } column(DocumentNo; "No.") { } column(CompanyLegalOffice; CompanyInformation.GetLegalOffice()) { } column(SalesPersonName; SalespersonPurchaserName) { } column(ShipmentMethodDescription; ShipmentMethodDescription) { } column(Currency; CurrencyCode) { } column(CustomerVATRegNo; GetCustomerVATRegistrationNumber()) { } column(CustomerVATRegistrationNoLbl; GetCustomerVATRegistrationNumberLbl()) { } column(PageLbl; PageLbl) { } column(DocumentTitleLbl; DocumentCaption()) { } column(YourReferenceLbl; FieldCaption("Your Reference")) { } column(ExternalDocumentNoLbl; FieldCaption("External Document No.")) { } column(CompanyLegalOfficeLbl; CompanyInformation.GetLegalOfficeLbl()) { } column(SalesPersonLbl; SalesPersonLblText) { } column(EMailLbl; CompanyInformation.FieldCaption("E-Mail")) { } column(HomePageLbl; CompanyInformation.FieldCaption("Home Page")) { } column(CompanyPhoneNoLbl; CompanyInformation.FieldCaption("Phone No.")) { } column(ShipmentMethodDescriptionLbl; DummyShipmentMethod.TableCaption()) { } column(CurrencyLbl; DummyCurrency.TableCaption()) { } column(ItemLbl; Item.TableCaption()) { } column(TariffLbl; Item.FieldCaption("Tariff No.")) { } column(UnitPriceLbl; Item.FieldCaption("Unit Price")) { } column(CountryOfManufactuctureLbl; CountryOfManufactuctureLbl) { } column(AmountLbl; Line.FieldCaption(Amount)) { } column(VATPctLbl; Line.FieldCaption("VAT %")) { } column(VATAmountLbl; DummyVATAmountLine.VATAmountText()) { } column(TotalWeightLbl; TotalWeightLbl) { } column(TotalAmountLbl; TotalAmountLbl) { } column(TotalAmountInclVATLbl; TotalAmountInclVATLbl) { } column(QuantityLbl; Line.FieldCaption(Quantity)) { } column(NetWeightLbl; Line.FieldCaption("Net Weight")) { } column(DeclartionLbl; DeclartionLbl) { } column(SignatureLbl; SignatureLbl) { } column(SignatureNameLbl; SignatureNameLbl) { } column(SignaturePositionLbl; SignaturePositionLbl) { } column(VATRegNoLbl; CompanyInformation.GetVATRegistrationNumberLbl()) { } dataitem(Line; "Sales Line") { DataItemLink = "Document Type" = FIELD("Document Type"), "Document No." = FIELD("No."); DataItemLinkReference = Header; DataItemTableView = SORTING("Document No.", "Line No."); column(ItemDescription; Description) { } column(CountryOfManufacturing; Item."Country/Region of Origin Code") { } column(Tariff; Item."Tariff No.") { } column(Quantity; "Qty. to Invoice") { } column(Price; FormattedLinePrice) { AutoFormatExpression = "Currency Code"; AutoFormatType = 2; } column(NetWeight; "Net Weight") { } column(LineAmount; FormattedLineAmount) { AutoFormatExpression = "Currency Code"; AutoFormatType = 1; } column(VATPct; "VAT %") { } column(VATAmount; FormattedVATAmount) { } trigger OnAfterGetRecord() var Location: Record Location; AutoFormatType: Enum "Auto Format"; begin GetItemForRec("No."); OnBeforeLineOnAfterGetRecord(Header, Line); if IsShipment() then if Location.RequireShipment("Location Code") and ("Quantity Shipped" = 0) then "Qty. to Invoice" := Quantity; if Quantity = 0 then begin LinePrice := "Unit Price"; LineAmount := 0; VATAmount := 0; end else begin LinePrice := Round(Amount / Quantity, Currency."Unit-Amount Rounding Precision"); LineAmount := Round(Amount * "Qty. to Invoice" / Quantity, Currency."Amount Rounding Precision"); if Currency.Code = '' then VATAmount := "Amount Including VAT" - Amount else VATAmount := Round( Amount * "VAT %" / 100 * "Qty. to Invoice" / Quantity, Currency."Amount Rounding Precision"); TotalAmount = LineAmount; TotalWeight = Round("Qty. to Invoice" * "Net Weight"); TotalVATAmount = VATAmount; TotalAmountInclVAT = Round("Amount Including VAT" * "Qty. to Invoice" / Quantity, Currency."Amount Rounding Precision"); end; FormattedLinePrice := Format(LinePrice, 0, AutoFormat.ResolveAutoFormat(AutoFormatType::UnitAmountFormat, CurrencyCode)); FormattedLineAmount := Format(LineAmount, 0, AutoFormat.ResolveAutoFormat(AutoFormatType::AmountFormat, CurrencyCode)); FormattedVATAmount := Format(VATAmount, 0, AutoFormat.ResolveAutoFormat(AutoFormatType::AmountFormat, CurrencyCode)); end; trigger OnPreDataItem() begin TotalWeight := 0; TotalAmount := 0; TotalVATAmount := 0; TotalAmountInclVAT := 0; //SetRange(Type, Type::Item); OnAfterLineOnPreDataItem(Header, Line); end; } dataitem(Totals; "Integer") { MaxIteration = 1; column(TotalWeight; TotalWeight) { } column(TotalValue; FormattedTotalAmount) { } column(TotalVATAmount; FormattedTotalVATAmount) { } column(TotalAmountInclVAT; FormattedTotalAmountInclVAT) { } trigger OnPreDataItem() var AutoFormatType: Enum "Auto Format"; begin FormattedTotalAmount := Format(TotalAmount, 0, AutoFormat.ResolveAutoFormat(AutoFormatType::AmountFormat, CurrencyCode)); FormattedTotalVATAmount := Format(TotalVATAmount, 0, AutoFormat.ResolveAutoFormat(AutoFormatType::AmountFormat, CurrencyCode)); FormattedTotalAmountInclVAT := Format(TotalAmountInclVAT, 0, AutoFormat.ResolveAutoFormat(AutoFormatType::AmountFormat, CurrencyCode)); end; } trigger OnAfterGetRecord() begin CurrReport.Language := Language.GetLanguageIdOrDefault("Language Code"); FormatDocumentFields(Header); if SellToContact.Get("Sell-to Contact No.") then; if BillToContact.Get("Bill-to Contact No.") then; end; } } requestpage { layout { } actions { } } labels { } trigger OnInitReport() begin CompanyInformation.Get(); CompanyInformation.CalcFields(Picture); end; var CompanyInformation: Record "Company Information"; Item: Record Item; DummyVATAmountLine: Record "VAT Amount Line"; DummyShipmentMethod: Record "Shipment Method"; DummyCurrency: Record Currency; Currency: Record Currency; Language: Codeunit Language; SellToContact: Record Contact; BillToContact: Record Contact; AutoFormat: Codeunit "Auto Format"; CompanyAddress: array[8] of Text[100]; CustomerAddress: array[8] of Text[100]; SalesPersonLblText: Text[50]; CountryOfManufactuctureLbl: Label 'Country'; TotalWeightLbl: Label 'Total Weight'; SalespersonPurchaserName: Text; ShipmentMethodDescription: Text; TotalAmountLbl: Text[50]; TotalAmountInclVATLbl: Text[50]; FormattedLinePrice: Text; FormattedLineAmount: Text; FormattedVATAmount: Text; FormattedTotalAmount: Text; FormattedTotalVATAmount: Text; FormattedTotalAmountInclVAT: Text; CurrencyCode: Code[10]; TotalWeight: Decimal; TotalAmount: Decimal; TotalVATAmount: Decimal; TotalAmountInclVAT: Decimal; LinePrice: Decimal; LineAmount: Decimal; VATAmount: Decimal; DocumentTitleLbl: Label 'Pro Forma Invoice'; PageLbl: Label 'Page'; DeclartionLbl: Label 'For customs purposes only.'; SignatureLbl: Label 'For and on behalf of the above named company:'; SignatureNameLbl: Label 'Name (in print) Signature'; SignaturePositionLbl: Label 'Position in company'; SellToContactPhoneNoLbl: Label 'Sell-to Contact Phone No.'; SellToContactMobilePhoneNoLbl: Label 'Sell-to Contact Mobile Phone No.'; SellToContactEmailLbl: Label 'Sell-to Contact E-Mail'; BillToContactPhoneNoLbl: Label 'Bill-to Contact Phone No.'; BillToContactMobilePhoneNoLbl: Label 'Bill-to Contact Mobile Phone No.'; BillToContactEmailLbl: Label 'Bill-to Contact E-Mail'; local procedure FormatDocumentFields(SalesHeader: Record "Sales Header") var GeneralLedgerSetup: Record "General Ledger Setup"; SalespersonPurchaser: Record "Salesperson/Purchaser"; ShipmentMethod: Record "Shipment Method"; ResponsibilityCenter: Record "Responsibility Center"; Customer: Record Customer; FormatDocument: Codeunit "Format Document"; FormatAddress: Codeunit "Format Address"; TotalAmounExclVATLbl: Text[50]; begin with SalesHeader do begin Customer.Get("Sell-to Customer No."); FormatDocument.SetSalesPerson(SalespersonPurchaser, "Salesperson Code", SalesPersonLblText); SalespersonPurchaserName := SalespersonPurchaser.Name; FormatDocument.SetShipmentMethod(ShipmentMethod, "Shipment Method Code", "Language Code"); ShipmentMethodDescription := ShipmentMethod.Description; FormatAddress.GetCompanyAddr("Responsibility Center", ResponsibilityCenter, CompanyInformation, CompanyAddress); FormatAddress.SalesHeaderBillTo(CustomerAddress, SalesHeader); if "Currency Code" = '' then begin GeneralLedgerSetup.Get(); GeneralLedgerSetup.TestField("LCY Code"); CurrencyCode := GeneralLedgerSetup."LCY Code"; Currency.InitRoundingPrecision(); end else begin CurrencyCode := "Currency Code"; Currency.Get("Currency Code"); end; FormatDocument.SetTotalLabels("Currency Code", TotalAmountLbl, TotalAmountInclVATLbl, TotalAmounExclVATLbl); end; end; local procedure DocumentCaption(): Text var DocCaption: Text; begin OnBeforeGetDocumentCaption(Header, DocCaption); if DocCaption <> '' then exit(DocCaption); exit(DocumentTitleLbl); end; local procedure GetItemForRec(ItemNo: Code[20]) var IsHandled: Boolean; begin IsHandled := false; OnBeforeGetItemForRec(ItemNo, IsHandled); if IsHandled then exit; //Item.Get(ItemNo); if Item.Get(ItemNo) then; end; [IntegrationEvent(false, false)] local procedure OnAfterLineOnPreDataItem(var SalesHeader: Record "Sales Header"; var SalesLine: Record "Sales Line") begin end; [IntegrationEvent(false, false)] local procedure OnBeforeGetDocumentCaption(SalesHeader: Record "Sales Header"; var DocCaption: Text) begin end; [IntegrationEvent(true, false)] local procedure OnBeforeGetItemForRec(ItemNo: Code[20]; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeLineOnAfterGetRecord(SalesHeader: Record "Sales Header"; var SalesLine: Record "Sales Line") begin end; }
Hope this helps.
Thanks.
ZHU
Hey ZHU, the comment is included in the item description. You should go through this link (community.dynamics.com/.../display-line-comments-on-proforma-invoice) for better understanding. Thank you.
Hi, I checked the standard code of report 1302 "Standard Sales - Pro Forma Inv" and the layout files (RDLC and Word), and there is no Comment Lines in it.
So, you need to use the report extension to add dataitem first, and then modify the layout file. I suggest you contact someone with development experience.
More details: https://yzhums.com/10723/
Hope this helps as well.
Thanks.
ZHU
The base Pro Forma Invoice report does not include Comments.
You would need a developer to add the Sales Line Comments to the report data.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,151 Super User 2024 Season 2
Martin Dráb 229,963 Most Valuable Professional
nmaenpaa 101,156