{"title":"AppSourceCop Error AS0013","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/analyzers/appsourcecop-as0013/","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-as0013, 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-as0013","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 field identifier must be within the allowed range and outside the range allocated to per-tenant customizations.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"AppSourceCop Error AS0013","slug":"appsourcecop-error-as0013","at":0,"chars":3879},{"level":2,"title":"Description","slug":"description","at":82,"chars":131},{"level":2,"title":"Remarks","slug":"remarks","at":213,"chars":780},{"level":2,"title":"Code examples","slug":"code-examples","at":993,"chars":884},{"level":3,"title":"Code example triggering the rule - Invalid Codeunit ID","slug":"code-example-triggering-the-rule---invalid-codeunit-id","at":1187,"chars":268},{"level":3,"title":"Code example triggering the rule - Invalid Table Extension Field ID","slug":"code-example-triggering-the-rule---invalid-table-extension-field-id","at":1455,"chars":422},{"level":2,"title":"How to fix this diagnostic?","slug":"how-to-fix-this-diagnostic","at":1877,"chars":1855},{"level":3,"title":"For new objects","slug":"for-new-objects","at":2223,"chars":224},{"level":3,"title":"For existing objects","slug":"for-existing-objects","at":2447,"chars":1285},{"level":4,"title":"Example - Modifying the ID of an existing codeunit","slug":"example---modifying-the-id-of-an-existing-codeunit","at":2803,"chars":929},{"level":2,"title":"Related information","slug":"related-information","at":3732,"chars":147}],"text":"# AppSourceCop Error AS0013\nThe field identifier must be within the allowed range\n## Description\nThe field identifier must be within the allowed range and outside the range allocated to per-tenant customizations.\n## Remarks\nTo avoid ID clashes for objects added by your extension and objects added by other extensions, you must respect the ID range specified in the app.json<../devenv-json-files> file of your extension when declaring new AL objects. For more information about ID ranges in Business Central, see ../devenv-object-ranges.\nThe following illustrates an example of an app.json file specifying an ID range:\n```json\n{\n    \"idRanges\":\n    [\n        {\n            \"from\": 1000000,\n            \"to\": 1000100\n        }\n    ]\n}\n```\n> NOTE\n> For table fields defined in table objects and enums defined in enum objects, it is possible to use an ID within the range `[0-49,999]`.\nThe rule appsourcecop-as0084 validates that the ID range has been specified in the app.json of the extension.\n## Code examples\nFor the following examples, let's consider this app.json:\n```json\n{\n    \"idRanges\":\n    [\n        {\n            \"from\": 1000000,\n            \"to\": 1000100\n        }\n    ]\n}\n```\n### Code example triggering the rule - Invalid Codeunit ID\nThe following example triggers the rule because the ID of the codeunit MyCodeunit is not defined within the ID range defined in the app.json file.\n```al\ncodeunit 50100 MyCodeunit\n{\n    // Business logic\n}\n```\n### Code example triggering the rule - Invalid Table Extension Field ID\nThe following example triggers the rule because the ID of the field MyField is not defined within the ID range defined in the app.json file.\n```al\ntableextension 1000000 MyTableExt extends MyTable\n{\n    fields\n    {\n        field(50100; MyField; Integer) { }\n    }\n}\n```\n> NOTE\n> Fields defined in table objects are validated by appsourcecop-as0099.\n## How to fix this diagnostic?\n> NOTE\n> If you are targeting the AppSource marketplace and do not have an ID range assigned, follow the steps defined in Get Started with Building Apps<../readiness/get-started>.\nIf you are not targeting the AppSource marketplace, you can suppress this rule using ../devenv-using-code-analysis-tool-with-rule-set.\n### For new objects\nFor objects that are introduced with the current version of the extension, changing the ID of the object will fix the diagnostic.\nChanging the ID of objects which are not part of the baseline is allowed.\n### For existing objects\nFor objects which already exist in the version of the extension used as baseline, it is not possible to change their ID. Instead, the offending object should be deprecated using the ../properties/devenv-obsoletestate-property property and a new object whose ID is within the range allocated for the extension should be introduced.\n#### Example - Modifying the ID of an existing codeunit\nAs an example, let's consider an extension if the ID range assigned to the extension is `[1,000,000 -  1,000,100]` and the extension defines:\n```al\ncodeunit 50100 MyCodeunit\n{\n    procedure MyProcedure()\n    begin\n        // Business logic.\n    end;\n}\n```\nThe extension should be modified into:\n```al\ncodeunit 50100 MyCodeunit\n{\n    ObsoleteState = Pending;\n    ObsoleteReason = 'Use MyNewCodeunit instead.';\n\n    procedure MyProcedure()\n    var\n        c: Codeunit MyNewCodeunit;\n    begin\n        // Re-direct calls to not break the runtime behaviour of dependent extensions.\n        c.MyProcedure();\n    end;\n}\n\ncodeunit 1000000 MyNewCodeunit\n{\n    procedure MyProcedure()\n    begin\n        // Business logic.\n    end;\n}\n```\nOnce all dependent extensions have been updated to use the codeunit MyNewCodeunit instead of MyCodeunit, the codeunit MyCodeunit can be removed.\n## Related information\nAppSourceCop Analyzer<appsourcecop>\nGet Started with AL<../devenv-get-started>\nDeveloping Extensions<../devenv-dev-overview>"}