Skip to main content

Notifications

Community site session details

Community site session details

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

Results from DataSet in AL Report

(0) ShareShare
ReportReport
Posted on by 49

Hi Guys,

Im developing a report. Nothing fancy but i have some trouble getting the data right.

The dataset looks like this:

        dataitem(Sales_Line; "Sales Line")
        {
            column(ItemNo; "No.") { }
            column(Variant_Code; "Variant Code") { }
            column(Quantity; Quantity)
            {
                // Method = Sum;
            }
            column(Sell_to_Customer_No_; "Sell-to Customer No.") { }
            dataitem(PItem; Item)
            {
                DataItemLink = "No." = field("No.");
                column(ItemDescription; Description) { }
            }
            dataitem(PurchaseLine; "Purchase Line")
            {
                DataItemLink = "No." = field("No."), "Variant Code" = field("Variant Code");
                //SqlJoinType = FullOuterJoin;

                column(PurchQuantity; Quantity)
                {
                    //Method = Sum;
                }

            }

        }
    }

The problem is that i get rows without some data in some fields. Like this:

ItemNo Variant_Code Quantity Sell_to_Customer_No_ ItemDescription PurchQuantity
001CAN Medium 1 7987 Item A - red                                                                                         NULL
001SAN Medium 1 7987 NULL NULL

This should only have been one row and it seems that the PurchQty from the Purchase Line table forces it to be another row added. Is this fixable?

If i use a query i get the right data but then i cant use report parameters, and i need to use it.

Thanks in advance!

  • Suggested answer
    Amit_Sharma Profile Picture
    2,545 on at
    RE: Results from DataSet in AL Report

    Send the AL and rdlc file.

    Regards

    Amit Sharma

    www.erpconsultors.com

  • Knofan Profile Picture
    49 on at
    RE: Results from DataSet in AL Report

    I don not se any difference in my report from this.

    Is there any way to manipulate the records in the OnPostDataItem trigger for example. Group them there and use that data instead? The problem is that i have at least two rows on each item, it should idealy be just one row. With all data.

    This is easy to do with querys but then it seems i can not use filters when i run the report. For example date filters.

  • Suggested answer
    Nitin Verma Profile Picture
    21,544 Moderator on at
    RE: Results from DataSet in AL Report

    Hi,

    trigger OnAfterGetRecord()

               begin

                   PurchaseLine.Reset;

                   PurchaseLine.SetFilter("Document Type", '%1', PurchaseLine."Document Type"::Order);

                   PurchaseLine.SetRange("No.", "No.");

                   PurchaseLine.SetRange("Variant Code", "Variant Code");

                   If PurchaseLine.FindFirst() then begin

                       QtyVariable := PurchaseLine.Quantity;

                   end;

               end;

  • Knofan Profile Picture
    49 on at
    RE: Results from DataSet in AL Report

    I had some trouble to get it to work with your example. Perhaps i have made a misstake somewhere.

    Here is what i have:

               trigger OnAfterGetRecord()

               begin

                   PurchaseLine.Reset;

                   PurchaseLine.SetFilter("Document Type", '%1', PurchaseLine."Document Type"::Order);

                   PurchaseLine.SetRange("No.", "No.");

                   PurchaseLine.SetRange("Variant Code", "Variant Code");

                   If PurchaseLine.FindFirst() then begin

                       PurchaseLine.Quantity := PurchaseLine.Quantity;

                   end;

               end;

  • Suggested answer
    Amit_Sharma Profile Picture
    2,545 on at
    RE: Results from DataSet in AL Report

    Hi,

    You can write code on onAftergetRecord of Sales Line Dataite.

    Purchase.reset;

    Purchase.Setfilter("Document Type",'%1',PurchaseLine.Document Type" :: Order);

    Purchase.Setrange("No.","No.")

    Purchase.Setrange("Variant Code",Variant Code");

    if PurchaseLine.findfirst then

    PurchaseQty := PurchaseLine.Quantity.

    In this way way you achive the functionality.

    Regards

    Amit Sharma

    www.erpconsultors.com

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,021 Moderator on at
    RE: Results from DataSet in AL Report

    I would add the type field to the data item link so you only handled lines of type item.

    Is your real problem that you get a NULL where there are no purchase lines matching your data item link?

  • Knofan Profile Picture
    49 on at
    RE: Results from DataSet in AL Report

    Yes, i need the sum on two columns. Is there anyway to change the dataset so that it outputs the data in a way that it can be used?

    It works great with a Query but within a report it does not work.

  • Suggested answer
    Nitin Verma Profile Picture
    21,544 Moderator on at
    RE: Results from DataSet in AL Report

    It would not total the Quantity unless you put the SUM method, it will group the Item No. so that It display only one time of each time, its up to you if you dont want to sum of the other columns.

    Thanks.

  • Knofan Profile Picture
    49 on at
    RE: Results from DataSet in AL Report

    Hello Nitin

    Thank you for your answer. That wont work since there are twice as much data as it should. Qty should only be one, when its grouped and summed it double from what it should.

    By only grouping on Item No the size "medium" apears twice for each Item.

  • Suggested answer
    Nitin Verma Profile Picture
    21,544 Moderator on at
    RE: Results from DataSet in AL Report

    Please use grouping on Item No. in RDLC design.

    Thanks

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,095 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans