Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

How to add data item on report extension

(0) ShareShare
ReportReport
Posted on by 225

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.
  • yoheswaran Profile Picture
    yoheswaran 225 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.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: How to add data item on report extension

    Can you confirm which report ID you are using?

    Thanks

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 74,115 Super User 2024 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

  • Sabina Sasu Profile Picture
    Sabina Sasu 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)

              {

              }

          }

  • yoheswaran Profile Picture
    yoheswaran 225 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 ?

  • Suggested answer
    Sabina Sasu Profile Picture
    Sabina Sasu 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
    yoheswaran 225 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
    NAV_with_Narang Profile Picture
    NAV_with_Narang 2,236 Super User 2024 Season 1 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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans