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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Transaction error on running report in test codeunit

(0) ShareShare
ReportReport
Posted on by
When i run any report in the test codeunits via the al test tool i get a transction error:
the error happens when in anyway when a report is run.
in the current version of the code it is trigger by Report.RunRequestPage
 
    Subtype = Test;
    TestPermissions = Disabled;
    EventSubscriberInstance = Manual;
    InherentPermissions = X;
 
[Test]
    [HandlerFunctions('CalculatePlanReportRequestPageHandler30D')]
    [CommitBehavior(CommitBehavior::Ignore)]
    [TransactionModel(TransactionModel::AutoCommit)]
    procedure CreateRequestionNone()
    var
        ReqLine: Record /Requisition Line/;
        ReqWorksheet: TestPage /Req. Worksheet/;
        CalculatePlan: Report /Calculate Plan - Req. Wksh./;
        /Req. Wksh. Template/: record /Req. Wksh. Template/;
        /Requisition Wksh. Name/: Record /Requisition Wksh. Name/;
        Fail: Boolean;
        Succes: Boolean;
        XmlParameters: Text;
    begin
        //[Scenario] A Requisition for an item is made
        //[Given] An item for a customer a vendor and a  Salesorder
        PrepareSetupEnabled();
        PrepareData();
        //[WHEN] when a Requisition is made
        //ReqWorksheet.OpenView();
        //    Commit();
        if /Req. Wksh. Template/.FindFirst() then begin
            /Requisition Wksh. Name/.setrange(/Worksheet Template Name/, /Req. Wksh. Template/.Name);
            if /Requisition Wksh. Name/.FindFirst() then;
        end;
        CalculatePlan.SetTemplAndWorksheet(/Req. Wksh. Template/.Name, /Requisition Wksh. Name/.Name);
        XmlParameters := Report.RunRequestPage(Report::/Calculate Plan - Req. Wksh./);
        LibraryReportDataset.RunReportAndLoad(Report::/Calculate Plan - Req. Wksh./, ReqLine, XmlParameters);
        Clear(CalculatePlan);
        //  ReqWorksheet.CalculatePlan.Invoke();
        ReqLine.SetRange(/No./, '150.160.170');
        ReqLine.FindFirst();
        ReqWorksheet.GoToRecord(ReqLine);
        CarryOutActionMessage(ReqWorksheet);
        Succes := false;
        ReqLine.SetRange(/No./, '150.160.170');
        if ReqLine.FindSet() then
            repeat
                if not (ReqLine./Planning Flexibility/ = ReqLine./Planning Flexibility/::None) then
                    Fail := true;
            until ReqLine.Next() = 0;
        if not Fail then
            Succes := true;
        //[THEN] then an a succesfull Procces should have happend;
        Assert.IsTrue(Succes, 'The Requisition should have been succesfull');
    end;
 
    [RequestPageHandler]
    [TransactionModel(TransactionModel::AutoCommit)]
    procedure CalculatePlanReportRequestPageHandler30D(var CalculatePlan: TestRequestPage /Calculate Plan - Req. Wksh./);
    begin
        CalculatePlan.StartingDate.SetValue(workdate());
        CalculatePlan.EndingDate.SetValue(CalcDate('+30D', WorkDate()));
        CalculatePlan.OK().Invoke();
    end;
 
The eventual purpose of this codeunit is to test out calculate plan of Requisition Worksheets.
Is there any solution to this problem?
 
I have the same question (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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,055 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,063 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 1,014 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans