UICop Warning AW0013

Groups containing promoted actions should not be hidden.

Description

From Business Central 2022 Wave 2, promoted actions defined in a hidden group are rendered on the promoted side of the action bar only if the 'Modern Action Bar' feature is disabled for the environment. If you want to always see these actions on the promoted side, remove the Visible property on the group. If you never want to see these actions on the promoted side, remove the Promoted property on the promoted actions.

Remarks

For Business Central 2022 release wave 1 (version 20) and earlier, promoted actions defined in a hidden group were rendered on the promoted side of the action bar, but hidden in non-promoted side of the action bar.

From Business Central 2022 release wave 2 (version 21), promoted actions defined in a hidden group are rendered on the promoted side of the action bar only if the 'Modern Action Bar' feature is disabled for the environment.

Code example triggering the rule

The following code triggers a diagnostic from this rule because MyGroup is hidden, but MyPromotedAction is Promoted.

page 50100 MyPage
{
    actions
    {
        area(Creation)
        {
            group(MyGroup)
            {
                Visible = false;

                action(MyPromotedAction)
                {
                    Promoted = true;
                }

                action(MyAction)
                {
                }
            }
        }
    }
}

Promoted actions are currently rendered on the promoted section of the command bar based on the Visible property set on the action, without considering their actual visibility in the default section of the command bar.

MyPromotedAction doesn't have the visible property set, so it's visible by default and the promoted action will be rendered in the promoted section of the command bar. However, since MyGroup is not visible, MyPromotedAction will also not be visible in the default section of the command bar.

Note

For versions of Business Central before 2022 release wave 2 (version 21), a similar behavior could be achieved by using the PromotedOnly property on MyPromotedAction. From version 21, the platform handles the duplicity of promoted actions.

How to fix this diagnostic?

There are three ways to fix this diagnostic depending on what you want to achieve:

1. Make the action group visible

page 50100 MyPage
{
    actions
    {
        area(Creation)
        {
            group(MyGroup)
            {
                action(MyPromotedAction)
                {
                    Promoted = true;
                }

                action(MyAction)
                {
                }
            }
        }
    }
}

There's no impact on the promoted section of the command bar as promoted actions remain visible. However, promoted actions and non-promoted actions become visible in the default section of the command bar.

Use this approach if you want the group and its actions to be visible.

2. Make the action group visible and adjust the properties of actions

page 50100 MyPage
{
    actions
    {
        area(Creation)
        {
            group(MyGroup)
            {
                action(MyPromotedAction)
                {
                    Promoted = true;
                    PromotedOnly = true;
                }

                action(MyAction)
                {
                    Visible = false;
                }
            }
        }
    }
}

There's no impact on the promoted section of the command bar as promoted actions remain visible. There's also no impact on the default section of the command bar since promoted actions are promoted only and non-promoted actions remain hidden.

Use this approach if you want to keep the current behaviour.

Important

The behavior of the PromotedOnly property changes with Business Central 2022 release wave 2 since the platform handles the duplicity of promoted actions.

3. Demote the actions in the group

page 50100 MyPage
{
    actions
    {
        area(Creation)
        {
            group(MyGroup)
            {
                Visible = false;

                action(MyPromotedAction)
                {
                }

                action(MyAction)
                {
                }
            }
        }
    }
}

There's no impact on the default section of the command bar since all actions remain hidden by the group. However, the promoted actions do not appear in the promoted section of the command bar anymore.

Use this approach if you didn't expect MyPromotedAction to appear in the promoted section of the command bar and you want to hide it completely.

UICop Analyzer
Getting Started with AL
Developing Extensions