Bewerken

Delen via


AppSourceCop Error AS0031

Actions that have been published must not be deleted.

Description

Actions that have been published must not be deleted, because it will break dependent extensions.

Remarks

Removing an action, which has been published isn't allowed because it will break dependent extensions which are referencing or modifying it.

Note

Renaming an action will also trigger this error. AppSourceCop will consider the renamed action as a new action, unrelated to the one defined in the previous version.

Note

From Business Central 2022 release wave 2 (version 21), removing the Promoted property on an action is also considered a breaking change, since the AL compiler automatically synthesizes an action reference for each promoted action.

How to fix this diagnostic?

If the action was removed, revert the change by adding back the action and mark it as Obsolete.

If the action was renamed in order to change its display string in the web client, consider using the Caption property instead.

If the action was renamed in order to comply with naming rules such as AS0011, consider obsoleting the action before introducing a new one in the next version of the app.

If the Promoted property was removed or set to false on an action, consider obsoleting the action before modifying the promoted property in the next version of the app.

Examples of errors for dependent extensions

The following examples show some of the compilation errors that will be reported on dependent extensions if an action is removed from one version to another.

Version 1.0 of the extension defines a page named MyPage that contains an action named MyAction. Version 2.0 does not define this action anymore.

Example 1 - Extensions modify this action

If a dependent extension modifies this action in a page extension or customization, when compiling against version 2.0, this will lead to a compilation error similar to The action 'MyAction' is not found in the target 'MyPage' (AL0271).

pageextension 50100 SomePageExtension extends MyPage
{
    actions
    {
        modify(MyAction)
        {
            Visible = true;
        }
    }
}

Example 2 - Extensions referencing this action as an anchor for a change

If a dependent extension uses this action as an anchor for a change in a page extension or customization, when compiling against version 2.0, this will lead to a compilation error similar to The action 'MyAction' is not found in the target 'MyPage' (AL0271).

pageextension 50100 SomePageExtension extends MyPage
{
    actions
    {
        addafter(MyAction)
        {
            action(SomeNewAction)
            {
            }
        }
    }
}

Example 3 - Extensions moving this action

If a dependent extension is moving this action in a page extension or customization, when compiling against version 2.0, this will lead to a compilation error similar to The action 'MyAction' is not found in the target 'MyPage' (AL0271).

pageextension 50100 SomePageExtension extends MyPage
{
    actions
    {
        movefirst(creation; MyAction)
    }
}

AppSourceCop Analyzer
Get Started with AL
Developing Extensions