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...
Unanswered

Adding Code to a report field / Summary issue.

(0) ShareShare
ReportReport
Posted on by 85

Hello experts, I have a sort of two  part question perhaps. I need to create a summary that resets every time the description is -. I have written a piece of code that accomplishes this with a loop that can keep track of the summary, and then reset when it sees the appropriate description. I wrote this on a page to test and then was hoping to add that value from the table/page to my report. But I am unable to get this to work.

My question then is where do I put this code? I have tried using it in a trigger on the table field, adding the code to an event on the page, and I have tried to subscribe to a report event (which I would figure is the right solution). On the report side I am subscribing to OnAfterGetRecordSalesInvoiceHeader. I have seen from the debugger that the code itself is summing properly but my report displays a 0 no matter what I've tried thus far.

Thank you,

  • divyeshchitte Profile Picture
    970 on at

    Can you paste the code of the report and provide some data example

  • James_French Profile Picture
    85 on at

    Hello Divyesh,

    The basis for my report is just a copy of the 10074 Sales Invoice (I used go-to definition to copy it) because i needed to add to the data set.

     column(SubtotalAmountFromInvoiceLine; TempSalesInvoiceLine.SubtotalAmountFromInvLine)

                           {

                           }

    This is the code I added the column to the report for

    This is the code I am using to get the number

      SalesInvLine.SetCurrentKey("Document No.");

                   SalesInvLine.SetRange("Document No.", rec."No.");

                   If SalesInvLine.Findset()

                   then

                       repeat

                           If (SalesInvLine.Description <> '~')

                           then begin

                               //SalesInvLine.SubtotalAmountFromInvLine := SalesInvLine.SubtotalAmountFromInvLine + SalesInvLine."Line Amount";

                               myInt := myInt + Rec."Line Amount"; //Creates the summation

                               Rec.SubtotalAmountFromInvLine := myInt; //Overwrites the old value with the new value per line.

                           end

                           else begin

                               myInt := 0; //resets the int value on the tilde. This will hopefully let us have the value not reset until the line AFTER the tilde.

                               //This way the tilde value will be the summation up until that point and the following will start at 0

                           end

                       until SalesInvLine.Next() = 0;

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 671 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 434 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 241 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans