web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

How to add data item on report extension

(0) ShareShare
ReportReport
Posted on by 231

Hi everyone,

I need to display the lot no details in Test report, I created a report extension 

  addlast("Sales Line")
        {
            dataitem("Reservation Entry"; "Reservation Entry")
            {
                DataItemLink = "Source ID" = FIELD("Document No.");
                column(Lot_No_1; "Lot No.")
                {
                }
           }
       }
I added the dataitem by using add last but i can't able to retrieve data is there any alternative solution for this.
Thanks in advance.
I have the same question (0)
  • Suggested answer
    NAV_with_Narang Profile Picture
    2,294 Moderator on at
    RE: How to add data item on report extension

    Hi - Best to copy the report and create a new one on 50000 ID range. That will make your work easier and is straightforward. Let the community know if in case you need the steps to copy a default report and create a new one

    Hope it helps

    Do verify the answer by clicking "YES" for "Did this answer your question" - if it helped you, so that others can benefit out of it too. Thankyou very much for taking out time to read

  • yoheswaran Profile Picture
    231 on at
    RE: How to add data item on report extension

    Thanks for the response is there any alternate solution we have i mean by write a code in onaftergetrecord() trigger, i did that too by using finding the reservation entry table with sales line. i am able to retrieve records ,but the value is not updating in reports

  • Suggested answer
    Sabina Sasu Profile Picture
    19 on at
    RE: How to add data item on report extension

    Hi,

    Since the Reservation entry is linked to a Sales line, and Sales Line has a composite key (meaning multiple fields form its key), you will need to link the Reservation entry by Source ID but also by Source Ref No (see below).

    addlast("Sales Line")

           {

               dataitem("Reservation Entry"; "Reservation Entry")

               {

                   DataItemLink = "Source ID" = FIELD("Document No."), "Source Ref No" = FIELD("Line No.");

                   column(Lot_No_1; "Lot No.")

                   {

                   }

              }

          }

    Finally, on the report layout, you will need to create a new group underneath but inside your Sales Line group as you might have one or more Lots per sales line.

    If you truly want an alternative, although less elegant, you can use a variable to store the lot numbers as 1 string of the reservation entries you iterate through with a loop. Make sure to reset this variable. You can also add a breakpoint if you want to debug this. See the code below:

    dataset

       {

           add(Line)

           {

               column(Lot_No_1; LotNos)

               {

               }

           }

           modify(Line)

           {

               trigger OnAfterAfterGetRecord()

               var

                   ResEntry: record "Reservation Entry";

               begin

                   LotNos := '';

                   ResEntry.SetFilter("Source ID", Line."Document No.");

                   ResEntry.SetFilter("Source Ref. No.", format(Line."Line No."));

                   if ResEntry.findset() then

                   repeat

                       LotNos := LotNos + ResEntry."Lot No." + ", ";

                   until ResEntry.next()=0;

               end;

           }

       }

       var

           LotNos: text;

    Hope this helps!

    Sabina

    Developer at LIDD Consultants

  • yoheswaran Profile Picture
    231 on at
    RE: How to add data item on report extension

    Thanks for the response Sabina,

    I cannot use add(Line) because its already available in standard report

    I wrote a code same as yours in modify("Sales Line")

     ReservationEntry.SetRange("Source Type", 37);

                   ReservationEntry.SetRange("Source ID", "Sales Line"."Document No.");

                   ReservationEntry.SetRange("Source Ref. No.", "Sales Line"."Line No.");

                   if ReservationEntry.FindSet() then begin

                       repeat

                           LotNo := ReservationEntry."Lot No.";

                       until ReservationEntry.next = 0;

    Do we need both code and dataitem ?

  • Sabina Sasu Profile Picture
    19 on at
    RE: How to add data item on report extension

    You will not need the dataitem anymore if you go with this alternative, as long as you add the LotNo variable like so:

    add("Sales Line")

          {

              column(Lot_No_1; LotNo)

              {

              }

          }

  • Suggested answer
    YUN ZHU Profile Picture
    95,307 Super User 2025 Season 2 on at
    RE: How to add data item on report extension

    Hi, just adding some info, hope the following helps as well.

    https://yzhums.com/10723/

    Thanks.

    ZHU

  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at
    RE: How to add data item on report extension

    Can you confirm which report ID you are using?

    Thanks

  • yoheswaran Profile Picture
    231 on at
    RE: How to add data item on report extension

    Thank you for the details i got it straight away from the data item i liked sales header and reservation entry instead of sales line.

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 3,377

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,696 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,512 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans