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...
Answered

Error when trying to post receipt from the code : "Unhandled UI : page 700 "

(0) ShareShare
ReportReport
Posted on by 5

Hello, I am a beginner developer in business central and I need your help: I am trying to simulate the creation of a purchase order using TestPage instead of Record, and I have the following error "unhandled ui: page 700" in the "Post" scenario of the purchase order when I run the code on the Business central performance Toolkit.

Here is my code:

codeunit 50200 "Create P.O With N Lines" implements "BCPT Test Param. Provider"
{
    SingleInstance = true;
    Subtype = test;

    var
        BCPTTestContext: Codeunit "BCPT Test Context";
        NoOfLinesToCreate: Integer;
        NoOfLinesParamLbl: Label 'Lines';
        NoSeries: record "No. Series";
        ParamValidationErr: Label 'Parameter is not defined in the correct format, the expected format is "%1"', Comment = '%1 explain format';
        LibraryRandom: codeunit "Library - Random";
        LibraryUtility: codeunit "Library - Utility";
        LibraryAssert: codeunit Assert;
        IsInitialised: Boolean;

    [PageHandler]
    procedure PageHandler(var PurchOrd: TestPage "Purchase Order")
    begin

    end;

    [ConfirmHandler]
    procedure ConfirmHandler(Quest: Text; var rep: Boolean)
    var
    /* ConfUpdateLines: label 'You have answered %1 field';
    purchaseOrder: TestPage "Purchase Order"; */
    begin
        rep := True;
    end;

    [StrMenuHandler]
    [Scope('OnPrem')]
    procedure StrMenuHandler(Options: Text[1024]; var Choice: integer; Instruction: Text[1024])
    begin
        Choice := 0;
    end;

    trigger OnRun();
    begin
        If not IsInitialised or true then begin
            InitTest();
            IsInitialised := true;
        end;
        CreatePurhaseOrder();
    end;


    [Test]
    [HandlerFunctions('StrMenuHandler,PageHandler,ConfirmHandler')]
    procedure CreatePurhaseOrder()
    var
        Vendor: Record Vendor;
        Item: Record Item;
        PurchaseOrder: TestPage "Purchase Order";
        i: integer;
        Location: Record Location;
        qt: Integer;
    begin
        if not Vendor.Get('20000') then Vendor.FindFirst();
        if not Item.get('70000') then Item.FindFirst();
        if not Location.Get('NOWMS') then Location.FindFirst();

        NoOfLinesToCreate := LibraryRandom.RandIntInRange(1, 15);

        BCPTTestContext.StartScenario('Add Order');
        PurchaseOrder.OpenNew();
        Commit();
        BCPTTestContext.EndScenario('Add Order');
        BCPTTestContext.UserWait();

        BCPTTestContext.StartScenario('Enter Account No.');
        PurchaseOrder."Buy-from Vendor No.".Value := Vendor."No.";
        Commit();
        BCPTTestContext.EndScenario('Enter Account No.');
        BCPTTestContext.UserWait();

        BCPTTestContext.StartScenario('Add Location');
        PurchaseOrder."Location Code".Value := Location.Code;
        Commit();
        BCPTTestContext.EndScenario('Add Location');
        BCPTTestContext.UserWait();


        for i := 1 to NoOfLinesToCreate do begin

            BCPTTestContext.StartScenario('Enter Line Item No.');
            PurchaseOrder.PurchLines."No.".SetValue(Item."No.");
            Commit();
            BCPTTestContext.EndScenario('Enter Line Item No.');
            BCPTTestContext.UserWait();

            BCPTTestContext.StartScenario('Enter Line Quantity');
            PurchaseOrder.PurchLines.Quantity.SetValue(LibraryRandom.RandIntInRange(1, 50));
            Commit();
            BCPTTestContext.EndScenario('Enter Line Quantity');
            BCPTTestContext.UserWait();

            PurchaseOrder.PurchLines.Next();
        end;
        BCPTTestContext.StartScenario('Release');
        PurchaseOrder.Release.Invoke();
        Commit();
        BCPTTestContext.EndScenario('Release');
        BCPTTestContext.UserWait();

        BCPTTestContext.StartScenario('Post');
        PurchaseOrder.Post.Invoke();
        Commit();
        BCPTTestContext.EndScenario('Post');
        BCPTTestContext.UserWait();


        PurchaseOrder.Close();

    end;

    procedure InitTest()
    var
        PurchaseSetup: Record "Purchases & Payables Setup";
        NoSeriesLine: Record "No. Series Line";
    begin
        PurchaseSetup.Get();
        PurchaseSetup.TestField("Order Nos.");
        NoSeriesLine.SetRange("Series Code", PurchaseSetup."Order Nos.");
        NoSeriesLine.FindSet(true, true);

        repeat
            if NoSeriesLine."Ending No." <> '' then begin
                NoSeriesLine."Ending No." := '';
                NoSeriesLine.Validate("Allow Gaps in Nos.", true);
                NoSeriesLine.Modify(true);
            end;
        until NoSeriesLine.Next() = 0;
        Commit();
        if Evaluate(NoOfLinesToCreate, BCPTTestContext.GetParameter(NoOfLinesParamLbl)) then;
    end;

    procedure GetDefaultParameters(): Text[1000]
    begin
        exit(CopyStr(NoOfLinesParamLbl + '=' + Format(10), 1, 1000));
    end;

    procedure ValidateParameters(Parameters: Text[1000])
    begin
        if StrPos(Parameters, NoOfLinesParamLbl) > 0 then begin
            Parameters := DelStr(Parameters, 1, StrLen(NoOfLinesParamLbl + '='));
            if Evaluate(NoOfLinesToCreate, Parameters) Then
                exit;
        end;
    end;


}
  • Suggested answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks.

  • D Ben Hadji Profile Picture
    5 on at

    Hello,

    thank you for your recommendations.

    (By the way, the second link does not work on my browser)

    Kindest redards,

    D.B Hadji

  • Verified answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Apologies, here you go:

    www.dynamicsuser.net/.../14

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 768 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 541 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 324 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans