Edit

Share via


AppSourceCop Hidden AS0133

Keys should not be added.

Description

Keys should not be added.

Remarks

This rule is not enabled by default since additive changes are generally allowed.

How to fix this diagnostic?

Revert the changes done by removing the keys that have been added.

Examples triggering this rule

Example 1 - Adding a key to a table with schema

Version 1 of the extension

table 50100 MyTable
{
    fields
    {
        field(1; MyField; Integer) { }
        field(2; MyOtherField; Integer) { }
    }
    keys
    {
        key(PK; MyField) { }
    }
}

Version 2 of the extension

table 50100 MyTable
{
    fields
    {
        field(1; MyField; Integer) { }
        field(2; MyOtherField; Integer) { }
    }
    keys
    {
        key(PK; MyField) { }
        key(NewKey; MyOtherField) { } // New table key.
    }
}

Example 2 - Adding a key to a table extension with schema

Version 1 of the extension

tableextension 50100 MyExtension extends SomeTable
{
    fields
    {
        field(50100; MyExtField; Integer) { }
        field(50101; MyOtherExtField; Integer) { }
    }
}

Version 2 of the extension

tableextension 50100 MyExtension extends SomeTable
{
    fields
    {
        field(50100; MyExtField; Integer) { }
        field(50101; MyOtherExtField; Integer) { }
    }
    keys
    {
        key(NewKey; MyOtherExtField) { } // New table extension key.
    }
}

Example not triggering this rule

Example - Adding a key to a table without schema

Version 1 of the extension

table 50100 MyTable
{
    TableType = Temporary;

    fields
    {
        field(1; MyField; Integer) { }
        field(2; MyOtherField; Integer) { }
    }
    keys
    {
        key(PK; MyField) { }
    }
}

Version 2 of the extension

table 50100 MyTable
{
    TableType = Temporary; // Temporary tables don't contribute to the schema.

    fields
    {
        field(1; MyField; Integer) { }
        field(2; MyOtherField; Integer) { }
    }
    keys
    {
        key(PK; MyField) { }
        key(NewKey; MyOtherField) { } // New table key.
    }
}

AppSourceCop Analyzer
Getting Started with AL
Developing Extensions