AL extension release · 11.0AL Developmentofficial - Microsoftderived - from the source, no model text

AL Language extension 11.0

AL Language extension 11.0 for Business Central 2023 release wave 1: released 2023-04-03; 34 changelog entries, 13 GitHub issues linked.

Changelog on the Visual Studio Marketplace · Business Central 2023 release wave 1

External Business Events

The new attribute ExternalBusinessEvent can mark a procedure to be an external event which will raise an event that an external service like dataverse can subscribe to it. This attribute can be used together with RequiredPermissions to add extra required permissions to subscribe to the event.

AL Explorer & Home

  • The new AL Explorer allows for better discoverability and easy navigation between AL objects.
  • AL Home brings you news about AL development to a place close to you.

Inherent Permissions

The new property InherentPermissions was added to objects that can have assigned permissions. AL developers can mark an object with this property, to take it out of the permissions system.

Actionable errors

The new methods AddAction and AddNavigationAction was added to the ErrorInfo type. AL developers can use these to make errors easy to fix for users.

Per File Code Analysis - Code Analysis Performance Overhaul

A major change has been made to the way we run code analyzers for large projects. The default behavior was changed so that we will only be running code analysis rules on the currently focused file on the VSCode editor instead of on the entire project. This dramatically decreases the time required to calculate the diagnostics for each file and significantly improves the total performance of the editor. On large projects, we have observed that calculating diagnostics for a specific file can now happen up to 40 times faster. This is because the time required now depends on the size of the active file, as compared to the size of the project. This change effectively allows real-time code analysis diagnostics on large projects.

The new behavior is controlled by the backgroundCodeAnalysis setting which has been extended to also control the scope of the code analyzers. The default value for the setting is File which corresponds to the new behavior. To revert to running all the analyzers, the Project value can be set in the user or workspace settings.

Code Analyzer Statistics

We have added the ability to see statistics for the runtime performance of the different code analyzer rules. By enabling the new setting outputAnalyzerStatistics on a project and building, developers will be able to see a helpful summary of the percentage of time spent by each analyzer and the related diagnostics that were produced by this rule. They can then selectively turn off rules which are too expensive by suppressing their diagnostics in a ruleset file.

Removed Legacy Runtime

The setting to use the legacy runtime has been deprecated and no longer has any effect. Setting files which include "al.useLegacyRuntime": true will report a deprecation warning, and the option should be removed.

GitHub Issues

  • #7067 AL0746 now throws an error when more than one auto-increment field has been defined in a table.
  • #7145 Improve the error message for AL0505
  • #7139 AL0432 fails to warn for use of Obsoleted enum values in properties e.g. InitValue, TableRelation, FlowField CalcFormula
  • #7184 Presence of unrelated XML file(s) causes AppSourceCop/PTECop rules AS0094/PTE0014 to throw exceptions instead of just ignoring them
  • #7159 Rule AS0098 is now enforced for protected variables.
  • #7190 Intellisense is very slow.
  • #6530 ‘#pragma warning’ is not indented and hinders expand/collapse
  • #6810 Better code visibility for Temporary Table
  • #657 Foreach on Text- Adding support for foreach statement for Text, Code, Label and TextConstant types. Introduced with Runtime version 10.2.
  • #7196 Code Action : Convert to use new ActionRef syntax … is truncated?
  • #7041 Case inside “Quoted Identifier” is syntax-highlighted as case keyword and start of block. Ditto begin, end, etc.?
  • #6140 AA0232 The FlowField XXX of “TableName” should be added to the SIFT key.
  • #7359 #pragma warning disable AL0432 is ignored when backgroundCodeAnalysis is set to “File”
  • #7357 Query Column with Count, Month or Year Method returns None as Data Type
  • #7116 Snapshot Debugging: VS Code “Specified argument was out of the range of valid values. (Parameter ‘index’)”

New AppSourceCop rules

  • AS0106 - Protected variables cannot be renamed or removed.
  • AS0107 - Protected variables cannot be made less accessible.
  • AS0108 - Protected variables cannot be change type.
  • AS0109 - The type of a table should not be changed from Normal to Temporary, because synchronizing the app will fail if the table contains data. Make sure to remove all data from the table before changing the table type to temporary.
  • AS0114 - The name attribute parameter of an external business event cannot be changed because it might break external subscribers.

New PerTenantExtensionCop rules

  • PTE0020 - Use the ‘application’ property instead of specifying an explicit dependency on Base Application. This rule is currently reporting as a warning, but it will report as an error in a future release.

Change in behavior of Abs(integer)

Fixing the issue where integer division didn’t return a decimal. The new behavior is now the following:

local procedure TestDivision()
    var
        i: Integer;
        j: Integer;
        d: Decimal;
    begin
        i := 5;
        j := -2;
        d := i / Abs(j); // d will be 2.5
    end;

New UICop rule

  • AW0015 - When targeting runtime versions lower than 10.0, actions with scope repeater must be promoted in order to appear on the repeater in the web client. From runtime version 10.0, actions with scope repeater are rendered also when they are not promoted.

Updated UICop rule

  • AW0012 - When targeting runtime versions higher or equal to 11.0, the AboutText and AboutTitle properties will not be flagged as not supported for actions and action groups inside parts.

New CodeCop rule

  • AA0246 - When suppressing diagnostics using #pargma warning disable, the code(s) of the diagnostics to suppress must be specified instead of suppressing all analyzer diagnostics and compiler warnings.

Bugs fixed

  • Fixed issue where duplicate error messages would be shown when a key vault url has multiple violations (AL1078).
  • Fixed issue where code actions may not be returned for a specific document, due to incorrect diagnostics being used for their discovery.
  • Optimized Code Action discovery to not run analysis on the entire project for every click, but only on the active document.

RecordRef.SetTable supports ShareTable

New overload for SetTable that supports specifying ShareTable, to share the same underlying table for temporary records.

Media.FindOrphans & MediaSet.FindOrphans

New methods for finding media and media sets that are no longer referenced, and can be deleted.

ReadIsolation on Record and RecordRef

New property that sets a record’s read isolation level. This influences what isolation level is used when reading from the database.

  • Default: Follows the table’s isolation behavior, same behavior as not choosing an isolation level.
  • ReadUncommitted: This behavior makes the record return uncommitted rows when reading. Also called dirty reads, as well as any new rows added.
  • ReadCommitted: Only allows for reads committed data, but does not guarantee that rows read will stay consistent throughout the entirety of the transaction.
  • RepeatableRead: Guarantees that two subsequent reads of the same rows will return the same data.
  • UpdLock: Useful if you are planning to write later in the transaction. No one else can take a UpdLock isolation level at the same time on the same record, meaning you avoid new rows being added during the transaction. Otherwise same guarantees as RepeatableRead

Report FormatRegion property

New report property for setting the format region for the report. The format region is specified using the .Net culture tag name (as en-US).

  • Set the default format region in the report object
report 50000 TestReport
{
    FormatRegion = 'da-DK';
}
  • Set the format region at runtime with an AL property for a report instance.
local procedure TestDivision()
var
    report: Report TestReport;
begin
    report.FormatRegion := 'da-DK';
end;
  • Set the format region at runtime in a report trigger.
trigger OnAfterGetRecord()
begin
    CurrReport.RegionFormat := 'da-DK';
end;

New virtual table to support Language selection

The following virtual table is added to allow drop down selection of languages and regions in pages (and request page):

  • Language Selection (ID 2000000050)
    • This table contains information about languages display name, language id, culture tag and application enabled. Primary key is “Name” (the display name).

URLs can be used as the ruleset location

A url can now be used as the location for both the al.rulesetPath setting and for included rulesets. This makes it possible to upload a ruleset to a centralized location and re-use it for different projects. The feature can be turned off for security reasons through the al.enableExternalRulesets setting.

An example for how to enable the feature:

"al.rulesetPath": "https://bcartifacts.azureedge.net/rulesets/appsource.default.ruleset.json"

An example of how it can be used in a ruleset:

{
    "name": "Personal Project ruleset",
    "description": "A list of project specific rules",
    "includedRuleSets": [
        {
            "action": "Default",
            "path": "https://bcartifacts.azureedge.net/rulesets/appsource.default.ruleset.json"
        }
    ],
    ...
    ]
}

This feature can be used from alc as well by including the -enableexternalrulesets argument.

InStream ResetPosition method

Add a method ResetPosition that will reset the position on the InStream instance and allow AL code to read all content from the beginning.

local procedure ResetStream();
var
    instr : InStream;
    b : Boolean;
begin
    b := instr.ResetPosition();
end;

InStream Position and Length properties

Adds the Position and Length properties that will return the current stream position and length.

local procedure StreamProperties();
var
    instr : InStream;
    Position : BigInteger;
    Length: BigInteger;
begin
    Position := instr.Position();
    Length := instr.Length();
end;

Go-To Implementation

To find which codeunits or enums implement an Interface, it is now possible to use the “Go To Implementations” command.

If the command is invoked on a procedure, it will find the implementations of that procedure on other codeunits as well.

Type Hierachy

If you want to figure out where are the extension objects to a given object, you can now use the “Type Hierarchy” functionality in VSCode to do so.

Code actions for refactoring Application Area property

A new code action is introduced that sets the default value for application area on a page or a report and clean up the duplicates this code action can be applied to an object, a document, a project or a workspace.

A new code action is introduced that cleans up the redundant application areas if a default value is set on a page or a report. This code action can be applied to an object, a document, a project or a workspace.

Go-To definition for Event Publisher in Event Subscriber

We have improved the syntax of event suscribers to allow specifying identifiers to reference the event you are subscribing to, and to reference the target element for trigger events.

The new syntax is as follows:

[EventSubscriber(ObjectType::Page, Page::MyPage, OnAfterActionEvent, MyAction, true, true)]

This syntax allows to navigate from the subscriber to the event and to see the event hover information. You can now also see who is subscribing to your events.

In order to facilitate the conversion, code actions have been introduced to convert one, some, or all event subscribers in your project or workspace to the new syntax.

Support for multiple package caches

The al.packageCachePath setting now supports specifying multiple directories to search for cached symbol packages. To specify multiple directories, use the following syntax:

{
    "al.packageCachePath": [".\.alpackages", ".\.alternativeCacheDirectory"]
}

When downloading symbols, the first entry in the list will be used as the directory to store newly downloaded symbols.

Support for overriding the PublicWebBaseURL server setting OnPrem

A new usePublicWebURLFromServer option has been added to the launch.json. If set to false, the PublicWebBaseURL server setting will be overriden with the server parameter of the launch.json when launching the browser as part of a launch configuration. This option only affects launch debug sessions to OnPrem servers. If set to true the PublicWebBaseURL server setting will be used. The default for this is true.

New customaction types: FlowTemplate, FlowTemplateGallery

Add two new CustomActionTypes, FlowTemplate and FlowTemplateGallery. The actions trigger web the client to open the Power Automate integration to create a new Power Automate flow from a specifc template or selection of templates.

FlowTemplate

Opens the Power Automate template wizard. The user can follow the wizard to create a flow using the specified template.

customaction(DirectAction) {
    CustomActionType = FlowTemplate;
    FlowTemplateId = '69569e22-054f-4577-870a-e905860e4319';
    FlowCaption = 'My New Flow';
}
Property Type Required? Description
FlowTemplateId guid Yes The ID of the template to open.
FlowCaption string No The default caption of the newly created flow.

FlowTemplateGallery

Opens the Power Automate template gallery, filtered to a specific category. The user can follow the wizard to create a flow using a template selected from the gallery.

customaction(DirectAction) {
    CustomActionType = FlowTemplateGallery;
    FlowTemplateCategoryName = 'd365bc_instant';
    FlowCaption = 'My New Flow';
}
Property Type Required? Description
FlowTemplateCategoryName string Yes The category of template to display.
FlowCaption string No The default caption of the newly created flow.

Attach to session and user debugging

Now the normal debugger is able to connect to ongoing sessions and to the next session for any specified user. For more information check AL debugging.

Miscellaneous

  • New warning when using of Obsolete properties on page areas and page action areas. From runtime 13.0, an error will be reported.
  • New warning when exposing a public method that has a parameter or a return value whose types have internal accessibility.
  • Improved the connection error messages triggered by the snapshot debugger.
  • XML files in an unsupported encoding will no longer cause code analyzers to crash.
  • When discovering code actions, only analyzers with code fixes will be executed.
  • New warning when making procedures of the same name as a built-in procedure.
  • Fixed RAD instabilities when working with large projects.
  • Fixed issue using Blob table fields in XmlPort objects.
  • Added documentation for system options and system option values on hover and when using IntelliSense.
  • Fixed an issue where overloads of DotNet functions with extra optional parameters would be considered ambiguous.
  • Fixed a crash that would occur when specifying a column as a target for a report extension’s addfirst/addlast modifier.
  • Added support for suggesting first available ordinal value for enum values in enums and enum extensions.
  • Marked UpdateKey parameter from RecordRef.FindSetand Record.FindSet as deprecated.
  • Added an indication that a table or record is temporary when hovering over definitions, variables and parameters.
  • New method on the database indicating whether or not you are in a write transaction.
  • AA0194 - Warning is no longer raised when a customaction does not define the FlowId property. Instead, a compiler warning will be raised if the FlowId property is not defined for customactions of type Flow. This warning will become an error in version 13.0.
  • Fixed crash when dependencies in the manifest are missing App name or publisher.
  • Improved the time to resolve assemblies from probing paths, especially for directories with a large number of assemblies.
  • For the Images, Scripts, and StyleSheets properties for control add-ins, it is now possible to specify multiple files within the same path string by using a combination of a valid literal path and wildcard characters (* and ?).
  • Syntax highlighting will no longer highlight bracket keywords when they are inside a quoted identifier.
  • Added a new warning for table fields with leading/trailing spaces as it can cause publishing failures.
  • Fixed an issue that would cause incomplete diagnostics to be emitted in the case of a project without AL files.
  • Fixed a crash that would occur when invoking a method on a protected array as part of an expression.
  • Fixed a crash that would occur when using a protected variable as an index on an array as part of an expression.
  • Fixed an issue where diagnostics would get stuck when using project mode.
  • Fixed an issue where multi-project workspace diagnostics may not be updated.
  • Fixed an issue where declaration diagnostics would ignore pragma and ruleset suppressions.
  • Deprecating InDataSet attribute used for global variables in Pages.
  • AL0754 diagnostic has been introduced for when the name of an object member conflicts with an internal member, which can lead to runtime issues. From runtime 14.0, an error will be reported.

Source: Visual Studio Marketplace, ms-dynamics-smb.al changelog, Microsoft’s text unchanged. Dates from the gallery’s upload records.