AL icon indicating copy to clipboard operation
AL copied to clipboard

ModalPageHandler: Unexpected CLR exception thrown

Open gregoral opened this issue 8 years ago • 9 comments

We're trying to test Extended Field Lookup Page and we're getting the following error: Unexpected CLR exception thrown.: System.NullReferenceException: Object reference not set to an instance of an object. Microsoft.Dynamics.Nav.Runtime.NavTestExecution.ShowLookupForm(Guid handle)

AL Extension Version: 2.0.47152 Server Version: 13.0.24690.0-RS

tableextension 50000 "G/L Account-Xyz" extends "G/L Account"  //15
{
    fields
    {
        field(50000; "F1-Xyz"; Code[10])
        {
            DataClassification = SystemMetadata;
            TableRelation = Location;
        }
    }
}

pageextension 50000 "G/L Account Card-Xyz" extends "G/L Account Card" //17
{
    layout
    {
        addlast(Reporting)
        {
            field("F1-Xyz"; "F1-Xyz")
            {
                ApplicationArea = All;
            }
        }
    }
}

codeunit 50001 "TestCodeunit-Xyz"
{
    Subtype = Test;
    TestPermissions = Disabled;

    [ModalPageHandler]
    procedure MyCancelPageHandler(var LocationList: TestPage "Location List")
    begin
        LocationList.Cancel().Invoke();
    end;

    [Test]
    [HandlerFunctions('MyCancelPageHandler')]
    procedure TestPageExtensionAction();
    var
        MyTestPage: TestPage "G/L Account Card";
        MyRec: Record "G/L Account";
    begin
        Initialize();
        MyTestPage.OpenEdit();
        MyTestPage.GoToRecord(MyRec);
        MyTestPage."F1-Xyz".Lookup();
        MyTestPage.Close();
    end;
}

gregoral avatar Sep 24 '18 21:09 gregoral

Hi @gregoral, can you try removing the line MyTestPage.Close() ?

I guess this is a similar issue to the one described in #2670.

qutreson avatar Sep 25 '18 06:09 qutreson

Yes it is a similar issue, and I have foud it ( but that issue is closed and is not exactly the same ). Quick testing shows the code works as expected on on al-2.0.46000 & server 13.0.24284-W1.

I have tried your suggestion, but the error is the same.

The two pages are completely different objects. MyTestPage ="G/L Account Card"; LookupPage = "Location List";

If I change the test to do a lookup on a W1 field then the code Works as expected.

MyTestPage."Gen. Bus. Posting Group".Lookup(); // this lookup works as expected

I have attached a sample extension code on 60100 range.

test.lookup.2018_09_25.zip

gregoral avatar Sep 25 '18 07:09 gregoral

I have stumbled upon a second issue, Page.RunModal(0, "Ext Record") doesn't work either. I get the following error message: The metadata object Page 0 was not found.

The expected behaviour is to run the default page for the record passed as parameter.

trigger OnAction()
var
    TestCode: Record "Test Code-Xyz";
begin
    TestCode.FindFirst();
    if Page.RunModal(0, TestCode) = Action::LookupOK then;
end;

I have attached a second test.extension.app with source. I don't know if I should creat a separate issue or not. Example code attached. test.lookup.2018 09 25.002.zip

gregoral avatar Sep 25 '18 10:09 gregoral

Can you log it as a separate issue? It will make it easier for us to keep track of them and make sure both problems are fixed.

qutreson avatar Sep 25 '18 10:09 qutreson

linking potentially related issue: #3839

gregoral avatar Sep 25 '18 11:09 gregoral

linking another potentially related issue: #3843 ( al.vsix version used plays a role )

gregoral avatar Sep 25 '18 13:09 gregoral

Hi @gregoral

I couldnt repro it on the latest build. Would you please try to get the latest build/extension and try it again?

Thanks and regards Pooya

PooyaKharamesh avatar Nov 06 '18 14:11 PooyaKharamesh

Hey guys, I also created a ModalPageHandler and a test procedure, but when I test it, I get the following error message: "Open record "Unhandled UI": ModalPage 209 in a new window"

Does anyone know where my mistake is?

grafik

malue19 avatar Jan 09 '19 09:01 malue19

Duplicate of https://github.com/microsoft/AL/issues/5158

AndreyKorepanov avatar Oct 07 '19 11:10 AndreyKorepanov