Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Customer Statement different Report ID for some Customers

Posted on by 501
Hi, 
We have 10 customers that works with a different Customer Statement report than the rest of the Customers. 
The Default on Report Selection Sales is 50116 with built in layout.


On the Special Customers we added Report 50103 on the Customer Document Layouts:


When I run the Customer Statement from the Customer Card, I get the Report Request page for ID 50116 (The Default Report) and not Report ID 50103:
I Know the Statement shows a dummy request page before printing the report. 
I checked the code and found the issue is in :
codeunit 8800 "Custom Layout Reporting" -- local procedure GetRequestParameters()
The Procedure goes directly into Report Selections instead of checking "Custom Report Selection" for a different Report ID for this specific customer. 

Would it be possible to add an Eventsubscriber here so that we can change the report ID. 
Or is there another work around for this?

thanks
Categories:
  • Verified answer
    Hein Kruger Profile Picture
    Hein Kruger 501 on at
    Customer Statement different Report ID for some Customers
    I resolved it by making use of the OnBeforeAction and OnAfterAction of the standard "Report Statement" Action. 

    OnBefore:
    Check the related customer "Custom Report Selection" and see if there is an ID assigned to the Customer Statement. 
    Then we check the "Report Selections" to see what ID is assigned to Customer Statement. 
    If the two are not the same then assign the "Custom Report Selection" Report ID to the "Report Statement" Report ID. In my case there are no Email Body changes or Custom Layouts that needs to be assigned. 

    After the report has been run we reassign the old Report ID back to "Custom Report Selection". 
    Its not good standard, but it does resolve my issue. 
     
       trigger OnBeforeAction()
                var
                    ReportSelections: Record "Report Selections";
                    CustomReportSelection: Record "Custom Report Selection";
                begin
                    Clear(ReportID);
                    CustomReportSelection.Reset();
                    CustomReportSelection.SetRange("Source Type", DATABASE::Customer);
                    CustomReportSelection.SetRange("Source No.", Rec."No.");
                    CustomReportSelection.SetRange(Usage, CustomReportSelection.Usage::"C.Statement");
                    if CustomReportSelection.FindFirst() then begin
                        ReportSelections.Reset();
                        ReportSelections.SetRange(Usage, ReportSelections.Usage::"C.Statement");
                        ReportSelections.SetRange(Sequence, '1');
                        ReportSelections.SetFilter("Report ID", '<>0');
                        if ReportSelections.FindFirst() then
                            if CustomReportSelection."Report ID" <> ReportSelections."Report ID" then begin
                                ReportID := ReportSelections."Report ID";
                                ReportSelections.Validate("Report ID", CustomReportSelection."Report ID");
                                ReportSelections.Modify(true);
                            end;
                    end;
                end;
     
                trigger OnAfterAction()
                var
                    ReportSelections: Record "Report Selections";
                begin
                    if ReportID <> 0 then begin
                        ReportSelections.Reset();
                        ReportSelections.SetRange(Usage, ReportSelections.Usage::"C.Statement");
                        ReportSelections.SetFilter("Report ID", '<>0');
                        ReportSelections.SetRange(Sequence, '1');
                        if ReportSelections.FindFirst() then begin
                            ReportSelections.Validate("Report ID", ReportID);
                            ReportSelections.Modify(true);
                        end;
                    end;
                end;
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    Khushbu Rajvi. 4,615 on at
    Customer Statement different Report ID for some Customers
    Zhu is correct, you can create new action to handle it.
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,698 Super User 2024 Season 2 on at
    Customer Statement different Report ID for some Customers
    Hi, maybe you could add a new action to handle this. But this sounds like a Microsoft problem.
     
    Thanks
    ZHU
     

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans