Pragma ImplicitWith directive in AL
APPLIES TO: Business Central 2020 release wave 2 and later
The #pragma implicitwith
instruction changes the compiler behavior to not create an implicit with
. This can be used as a temporary solution to avoid getting warnings on the usage of implicit with
statements in the code, that you plan on rewriting but just haven't fixed yet. With the #pragma implicitwith disable
, you disable the emit of implicit with
warnings for a specific location in code that follows the instruction, and with #pragma implicitwith restore
you restore the warning back to its original state. If you don't restore
, the disable
instruction is valid for the rest of the file.
In the app.json
file, you can set the NoImplicitWith
flag to disable implicit with
when you've rewritten all code. For more information, see JSON Files.
Note
With Business Central 2022 release wave 2, the AL:Go! template for creating new AL projects in Visual Studio Code, now enables explicit with
statements by default, by adding the NoImplicitWith
option to the features
property in the generated app.json file.
Important
It's important to be aware that the implicitwith
warning will become an error in a future release and therefore suppressing it should be a temporary solution. It's recommended to rewrite code as described in Deprecating Explicit and Implicit With Statements.
Syntax
#pragma implicitwith disable
#pragma implicitwith restore
Example
For more background information and examples, see Deprecating Explicit and Implicit With Statements.
See also
Development in AL
AL development environment
Pragma directive in AL
Conditional directives
Deprecating explicit and implicit with statements