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 TestPage variable (local, global, or var parameter) whose target page has PageType = ListPart or PageType = CardPart.
  • The call is Invoke(), Enabled(), or Visible() on any action of that page — these are the only members of the built-in TestAction class, and all three fail identically at runtime.
  • Actions added by a pageextension that extends the part page are included.
  • Obsolete code is not exempt: an obsolete part page, an [Obsolete] test method and an ObsoleteState = Pending test 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 other TestPage built-in methods — these are not TestAction members.
  • Built-in system actions OK(), Cancel(), Yes(), No(), View(), Edit() — these are methods of the TestPage itself, not actions declared on the part page.
  • TestRequestPage variables — request pages are not ListPart or CardPart.
#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