{"title":"AppSourceCop Error AS0043","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/analyzers/appsourcecop-as0043/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/appsourcecop-as0043, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/appsourcecop-as0043","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"The clustered key must not be deleted.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"AppSourceCop Error AS0043","slug":"appsourcecop-error-as0043","at":0,"chars":2086},{"level":2,"title":"Description","slug":"description","at":66,"chars":377},{"level":2,"title":"How to fix this diagnostic?","slug":"how-to-fix-this-diagnostic","at":443,"chars":166},{"level":2,"title":"Code examples triggering the rule","slug":"code-examples-triggering-the-rule","at":609,"chars":1330},{"level":3,"title":"Example 1 - Removing the clustered key","slug":"example-1---removing-the-clustered-key","at":971,"chars":418},{"level":3,"title":"Example 2 - Renaming the clustered key","slug":"example-2---renaming-the-clustered-key","at":1389,"chars":550},{"level":2,"title":"Related information","slug":"related-information","at":1939,"chars":147}],"text":"# AppSourceCop Error AS0043\nThe clustered key must not be deleted\n## Description\nThe clustered key must not be deleted.\nIt's not allowed to rename or remove the clustered key in a table. For more information on table keys, see ../devenv-table-keys.\n> NOTE\n> This rule validates tables independently of their Accessibility or ObsoleteState, because tables are always used when synchronizing the schema defined in the extension to the database.\n## How to fix this diagnostic?\nTo fix this diagnostic, you must rename the clustered key or add it back so that it matches its definition in your baseline extension.\n## Code examples triggering the rule\nVersion 1.0 of the extension:\n```al\ntable 50100 MyTable\n{\n    fields\n    {\n        field(1; MyIntegerField; Integer) { }\n        field(2; MyTextField; Text[50]) { }\n    }\n\n    keys\n    {\n        key(PK; MyIntegerField) { }\n\n        key(ClusteredKey; MyTextField)\n        {\n            Clustered = true;\n        }\n    }\n}\n```\n### Example 1 - Removing the clustered key\nVersion 2.0 of the extension:\n```al\ntable 50100 MyTable\n{\n    fields\n    {\n        field(1; MyIntegerField; Integer) { }\n        field(2; MyTextField; Text[50]) { }\n    }\n\n    keys\n    {\n        key(PK; MyIntegerField) { }\n    }\n}\n```\nIn version 2.0 of the extension, the clustered key ClusteredKey has been removed. This change is not allowed by the synchronization engine.\n### Example 2 - Renaming the clustered key\n```al\ntable 50100 MyTable\n{\n    fields\n    {\n        field(1; MyIntegerField; Integer) { }\n        field(2; MyTextField; Text[50]) { }\n    }\n\n    keys\n    {\n        key(PK; MyIntegerField) { }\n\n        key(NewClusteredKey; MyTextField)\n        {\n            Clustered = true;\n        }\n    }\n}\n```\nIn version 2.0 of the extension, the clustered key has been renamed from ClusteredKey to NewClusteredKey. This change is detected as a removal of ClusteredKey and is not allowed by the synchronization engine.\n## Related information\nAppSourceCop Analyzer<appsourcecop>\nGet Started with AL<../devenv-get-started>\nDeveloping Extensions<../devenv-dev-overview>"}