Actions cannot be invoked on a part page opened directly through its own TestPage variable
Properties
TA0002
Warning
Usage
Code Fix
Ignore Obsolete
A ListPart or CardPart page opened directly through its own TestPage variable renders no actions at runtime. The platform resolves actions only when the part is hosted inside another page and reached through its part(...) control. Calling Invoke(), Enabled(), or Visible() on any action of a directly opened part page fails with:
The action with ID = xxx is not found on the page.
To reach the action in a test, open the hosting page and invoke the action through the part control: MainPage.SubPagePart.MyAction.Invoke().
Example
page 50100 "Item Subpage"
{
PageType = ListPart;
SourceTable = Item;
actions
{
area(processing)
{
action(UpdatePrices) { }
}
}
}
codeunit 50100 "Item Test"
{
Subtype = Test;
[Test]
procedure PriceUpdateTest()
var
ItemSubPage: TestPage "Item Subpage";
begin
ItemSubPage.OpenView();
ItemSubPage.UpdatePrices.Invoke(); // Action 'UpdatePrices' cannot be invoked on page 'Item Subpage' opened directly because its PageType is ListPart; invoke it through the part control of the hosting page instead. [TA0002]
end;
}Open the hosting page instead and invoke the action through its part control.
page 50101 "Item Card"
{
PageType = Card;
SourceTable = Item;
layout
{
area(content)
{
part(ItemLines; "Item Subpage") { }
}
}
}
codeunit 50100 "Item Test"
{
Subtype = Test;
[Test]
procedure PriceUpdateTest()
var
ItemCard: TestPage "Item Card";
begin
ItemCard.OpenView();
ItemCard.ItemLines.UpdatePrices.Invoke();
end;
}When the diagnostic is reported
- The receiver is a
TestPagevariable (local, global, orvarparameter) whose target page hasPageType = ListPartorPageType = CardPart. - The call is
Invoke(),Enabled(), orVisible()on any action of that page — these are the only members of the built-inTestActionclass, and all three fail identically at runtime. - Actions added by a
pageextensionthat extends the part page are included. - Obsolete code is not exempt: an obsolete part page, an
[Obsolete]test method and anObsoleteState = Pendingtest codeunit are all reported, because the test runner still executes the test and the runtime failure is real.
Exception
The diagnostic is not raised for:
- Field access on a directly opened part page — fields work without the hosting page.
OpenView(),OpenEdit(),OpenNew()and otherTestPagebuilt-in methods — these are notTestActionmembers.- Built-in system actions
OK(),Cancel(),Yes(),No(),View(),Edit()— these are methods of theTestPageitself, not actions declared on the part page. TestRequestPagevariables — request pages are notListPartorCardPart.
#pragma warning disable TA0002 // This test deliberately asserts the platform error for an action on a directly opened part.
asserterror ItemSubPage.UpdatePrices.Invoke();
#pragma warning restore TA0002
See also
- TestPage Data Type on Microsoft Learn