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

I have the same question (0)
  • divyeshchitte Profile Picture
    968 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

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,092

#2
YUN ZHU Profile Picture

YUN ZHU 663 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 515

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans