Dynamics 365 Business Central 2023 wave 1 (BC22) is generally available last month. More details: Dynamics 365 Business Central 2023 release wave 1 (BC22)
I will continue to test and share some new features that I hope will be helpful.
This new feature is mentioned in AL Language extension changelog version 11.0.
New warning when making procedures of the same name as a built-in procedure.
As you might know, in AL, procedure overloading or function overloading is the ability to create multiple functions of the same name with different implementations.
Procedure overload enables developers to create multiple procedures with the same name, but with different signatures, on the same application object. Conceptually, overloaded procedures are used to execute the same task on a different set of arguments. When an overloaded procedure is called, a specific implementation of that procedure, appropriate to the context of the call, will be run.https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods/devenv-overload-method
Here is a simple example:
So when you create multiple procedures, they are allowed to have the same name. This update is mainly for global procedures and warning when the name is the same as the standard one.
Let’s see more details. It’s really quite simple. When you extend a table or page, if you create a global procedure name that is the same as the one already defined in the standard, the following warning will be prompted.
For example, in pageextension: AL0523
The ‘Page “Customer List”‘ already defines a method called ‘GetSelectionFilter’ with the same parameter types in ‘Base Application by Microsoft (22.0.54157.55291)’. This warning will become an error in a future release.
In the Base Application:
PS: There is no warning if it is defined as local procedure.
And in the tableextension:
1. In reportextension an error will be prompted directly instead of a warning. AL0440
2. If the procedure has the same name as the system method or database method, it does not show a warning.
For exmaple, System.Format(Any, Integer, Text) Method and Database.CopyCompany(Text, Text) Method
3. I tested it in previous versions and found that this warning has been there since before, I’m not sure if it hasn’t been updated yet. I will update this post if there is any update. Anyway, when naming functions, please avoid conflicts with the standard.
Hope this will help.
Thanks for reading.