Can you pass a parameter to a Page using RunObject?

476 Views Asked by At

I have a role center page which I've set up with a few actions. Clicking the action will open a list page which is pre filtered (using RunPageView). I would like to pass the filter to the list page somehow but cant seem to find the answer out there.

The role center page is set up like this:

page 50125 "My Role Center"
{
    PageType = RoleCenter;
    Caption = 'My Role Center';
    Extensible = true;

    layout
    {
        ...
    }

    actions
    {
        area(Processing)
        {
            action(MyAction1)
            {
                Caption = 'My Action 1';
                RunPageView = where("Type" = filter('Type1'));
                RunObject = Page "My List Page";
            }
            action(MyAction2)
            {
                Caption = 'My Action 2';
                RunPageView = where("Type" = filter('Type2'));
                RunObject = Page "My List Page";
            }
        }
    }
}

The list page it opens up is something like this:

page 50126 "My List Page"
{
    Caption = 'My Page';
    ApplicationArea = All;
    PageType = List;

    layout
    {
        ...
    }

    trigger OnOpenPage()
    begin
       // I would like to get the filter here if possible
    end;
}

Is this possible?

1

There are 1 best solutions below

1
On BEST ANSWER

You have stumbled upon what is known as FilterGroups.

Filtering records can be done in various groups. This can be done either through code or it is done automatically in some situations.

The default FilterGroup is 0 which means that in the OnOpenPage trigger you will only see filters from FilterGroup 0 when you call e.g. GetFilter(...).

RunPageView uses FilterGroup 3 which means you can get to your filters like this:

trigger OnOpenPage()
var
    TypeFilter: Text;
begin
    Rec.FilterGroup(3);
    TypeFilter := Rec.GetFilter(Type);
    Rec.FilterGroup(0);
end;

You should always reset the FilterGroup to 0 to avoid any unintended behavior.

The full list of available FilterGroups can be found in the documentation.