AppSourceCop Error AS0004

Fields must not change type, since dependent extensions may break

Description

Fields must not change type.

Note

This rule validates all fields independently of their Accessibility or ObsoleteState, because they are used when synchronizing the schema defined in the extension to the database.

Remarks

The validation of the length of table fields was previously done with AS0004 and has now been split into two different rules:

  • AS0080 - which validates against decreasing the length of fields
  • AS0086 - which validates against increasing the length of fields

How to fix this diagnostic?

To fix this diagnostic, you must obsolete the field by mark the field as Obsolete Pending and then introduce a new field.

Example

Version 1.0 of the app:

table 50 MyTable
{
    fields
    {
        field(1; Identifier; Integer) { }
    }
}

Version 2.0 of the app:

table 50 MyTable
{
    fields
    {
        field(1; Identifier; Text[30]) { }
    }
}

The data type of the field Identifier was changed from Integer to Text[30], which isn't allowed and will trigger this rule.

AppSourceCop Analyzer
Get Started with AL
Developing Extensions