ModalPageHandler: Unexpected CLR exception thrown
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;
}
Hi @gregoral, can you try removing the line MyTestPage.Close() ?
I guess this is a similar issue to the one described in #2670.
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.
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
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.
linking potentially related issue: #3839
linking another potentially related issue: #3843 ( al.vsix version used plays a role )
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
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?

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