Skip to main content

Notifications

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

Transaction error on running report in test codeunit

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?
 

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans