{"title":"AppSourceCop Error AS0023","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/analyzers/appsourcecop-as0023/","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-as0023, 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-as0023","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":"A return type cannot be modified in external procedures.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"AppSourceCop Error AS0023","slug":"appsourcecop-error-as0023","at":0,"chars":5083},{"level":2,"title":"Description","slug":"description","at":84,"chars":72},{"level":2,"title":"Remarks","slug":"remarks","at":156,"chars":533},{"level":2,"title":"How to fix this diagnostic?","slug":"how-to-fix-this-diagnostic","at":689,"chars":417},{"level":2,"title":"Code examples triggering the rule","slug":"code-examples-triggering-the-rule","at":1106,"chars":2243},{"level":3,"title":"Example 1 - Changing the return type of a procedure from Integer to Boolean","slug":"example-1---changing-the-return-type-of-a-procedure-from-integer-to-boolean","at":1395,"chars":798},{"level":3,"title":"Example 2 - Removing the return type of a procedure","slug":"example-2---removing-the-return-type-of-a-procedure","at":2193,"chars":722},{"level":3,"title":"Example 3 - Removing the return type of a procedure and adding a TryFunction attribute","slug":"example-3---removing-the-return-type-of-a-procedure-and-adding-a-tryfunction-attribute","at":2915,"chars":434},{"level":2,"title":"Code examples not triggering the rule","slug":"code-examples-not-triggering-the-rule","at":3349,"chars":1587},{"level":3,"title":"Example 1 - Adding a return type to a procedure","slug":"example-1---adding-a-return-type-to-a-procedure","at":3622,"chars":858},{"level":3,"title":"Example 2 - Adding a TryFunction attribute to a procedure","slug":"example-2---adding-a-tryfunction-attribute-to-a-procedure","at":4480,"chars":456},{"level":2,"title":"Related information","slug":"related-information","at":4936,"chars":147}],"text":"# AppSourceCop Error AS0023\nA return type cannot be modified in external procedures\n## Description\nA return type cannot be modified in external procedures.\n## Remarks\nThis rule validates that the return type of a public procedure has not been changed in a way that would break the compilation of dependent extensions.\nIt is not allowed to change the return type of a public procedure that was published with a return type in a previous version.\nAdding a return type is allowed by this rule, but is validated by appsourcecop-as0102.\n> NOTE\n> This rule also covers the cases related to the ../attributes/devenv-tryfunction-attribute attribute which implicitly defines a Boolean return type.\n## How to fix this diagnostic?\nReverting the change will fix this diagnostic. If changing the return type is required, the recommended approach is to mark the procedure with the ../attributes/devenv-obsolete-attribute attribute and introduce a new one with the desired return type. In a future version, once all dependent extensions have updated their code to not reference the obsolete procedure, you can remove it.\n## Code examples triggering the rule\nIn the following examples, version 1.0 of the extension defines a public procedure which returns an Integer.\nVersion 1.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    procedure MyProcedure(): Integer\n    begin\n        exit(5);\n    end;\n}\n```\n### Example 1 - Changing the return type of a procedure from Integer to Boolean\nVersion 2.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    procedure MyProcedure(): Boolean\n    begin\n        exit(true);\n    end;\n}\n```\nIn version 2.0, the return type of MyProcedure has changed from Integer to Boolean. If a dependent extension used the return type of this procedure, this will lead to a compilation error similar to `Cannot implicitly convert type 'Boolean' to 'Integer' (AL0122)`.\nFor example, the following extension compiles when depending on version 1.0, but fails to compile with version 2.0:\n```al\ncodeunit 50120 AnotherCodeunit\n{\n    procedure AnotherMethod()\n    var\n        c: Codeunit MyCodeunit;\n        myInt: Integer;\n    begin\n        myInt := c.MyProcedure();\n    end;\n}\n```\n### Example 2 - Removing the return type of a procedure\nVersion 2.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    procedure MyProcedure()\n    begin\n    end;\n}\n```\nIn version 2.0, the procedure does not return anything anymore. If a dependent extension used the return type of this procedure, this will lead to a compilation error similar to `Cannot implicitly convert type 'None' to 'Integer' (AL0122)`.\nFor example, the following extension compiles when depending on version 1.0, but fails to compile with version 2.0:\n```al\ncodeunit 50120 AnotherCodeunit\n{\n    procedure AnotherMethod()\n    var\n        c: Codeunit MyCodeunit;\n        myInt: Integer;\n    begin\n        myInt := c.MyProcedure();\n    end;\n}\n```\n### Example 3 - Removing the return type of a procedure and adding a TryFunction attribute\nVersion 2.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [TryFunction]\n    procedure MyProcedure()\n    begin\n        exit(true);\n    end;\n}\n```\nIn version 2.0, the procedure now returns a Boolean value because it is marked as a TryFunction. This scenario would lead to the same compilation errors than mentioned in Example 1 above.\n## Code examples not triggering the rule\nIn the following examples, the version 1.0 of the extension defines a procedure which does not have a return type.\nVersion 1.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    procedure MyProcedure()\n    begin\n    end;\n}\n```\n### Example 1 - Adding a return type to a procedure\nVersion 2.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    procedure MyProcedure(): Boolean\n    begin\n        exit(true);\n    end;\n}\n```\nIn version 2.0, the procedure MyProcedure is now returning a boolean. However, it does not break the compilation of dependent extensions because they were not consuming the return type of the procedure.\n> IMPORTANT\n> Adding a return type to a procedure is a runtime breaking changes. Dependent extensions that are referencing the procedure must be recompiled in order to avoid experiencing issues at runtime. For on-premises installations this can be done using https://learn.microsoft.com/powershell/module/microsoft.dynamics.nav.apps.management/repair-navapp. For SaaS, we do not allow adding return types, this is validated by the rule appsourcecop-as0102.\n### Example 2 - Adding a TryFunction attribute to a procedure\nVersion 2.0 of the extension:\n```al\ncodeunit 50100 MyCodeunit\n{\n    [TryFunction]\n    procedure MyProcedure()\n    begin\n        exit(true);\n    end;\n}\n```\nIn version 2.0, the procedure is now marked as a TryFunction. This means that this return type has implicitly been changed to Boolean. Similarly, it is possible to add a TryFunction attribute on a function that already returned a Boolean.\n## Related information\nAppSourceCop Analyzer<appsourcecop>\nGet Started with AL<../devenv-get-started>\nDeveloping Extensions<../devenv-dev-overview>"}