Business Central 2022 wave 2 (BC21) new features: Enable NoImplicitWith feature by default (New feature setting in app.json file)

Dynamics 365 Business Central

Hi, Readers.
The preview environment for Dynamics 365 Business Central 2022 release wave 2 (BC21) is available. Learn more: Link.

I will continue to test and share some new features that I hope will be helpful.

Enable NoImplicitWith feature by default:

Business value:

In Business Central 2020 release 2 we added support for explicit WITH code statements and recommended using this instead of the legacy implicit WITH code statements, which can lead to issues with clashing identities. To promote the use of the explicit WITH statement, we have now updated the AL:Go template for new AL projects in Visual Studio Code to enable explicit WITH statements by default.

https://docs.microsoft.com/en-us/dynamics365-release-plan/2022wave2/smb/dynamics365-business-central/enable-noimplicitwith-feature-default

When you start a new AL project in Visual Studio Code using the AL:Go template.

The implicit WITH code statements will now be switched off by default to encourage using explicit WITH statements going forward. This is done by adding the NoImplicitWith option to the features property in the generated app.json file.

NoImplicitWith: Switch off the option of using implicit withs.

The implicit ‘with’ changes from a warning to an error when the NoImplicitWith flag is specified. (By default now)

The name ‘No.’ does not exist in the current context.

Removing the NoImplicitWith option changes back to a warning.

Use of implicit ‘with’ will be removed in the future. Qualify with ‘Rec’. This warning will become an error in a future release.

So when the NoImplicitWith flag is specified, ImplicitWith will be turned off by default. This flag is useful when all code has been rewritten to avoid any future use of ImplicitWith. For more information, see Pragma ImplicitWith and Deprecating Explicit and Implicit With Statements.

As of now in the BC21 preview environment, it is still possible to install the extension containing ImplicitWith, but it is recommended to update your code as soon as possible.

PS:
1. In the standard code of BC21, this part has also been updated.

2. You can use AL Code Actions to quickly fix implicit with statements.
More details: Using AL Code Actions

Update from Business Central Launch Event (2022 release wave 2) 

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL