Dynamics 365 Business Central: Suggest object ID in AL (Get the next available object ID)

Dynamics 365 Business Central

Hi, Readers.
Today I would like to share another mini tip about Business Central, suggest object ID in AL.

All functionality in Business Central is coded in objects. The extension model is object-based; you create new objects, and extend existing objects depending on what you want your extension to do.

So when you develop an app for Business Central online, you must request an object range in terms of licensing. Development for Business Central is done using Visual Studio Code with the AL Language extension for Microsoft Dynamics 365 Business Central.

Depending on the object range, the type of extension is also different. More details: Object ranges in Business Central

And objects of the same type and the same ID in the same environment cannot be repeated.

An application object of type ‘Codeunit’ with ID ‘50111’ is already declared by the extension ‘BC26P by YUN ZHU (26.0.0.0)’ AL AL0264

Generally, when we assign the next ID to be used, we need to find the last ID that has been used. Of course, some large projects may use external files to manage the IDs to be used, especially when multiple people are developing at the same time. But did you know that AL Language can directly propose the next usable ID? We only need to use VS Code IntelliSense features.

VS Code IntelliSense features are powered by a language service. A language service provides intelligent code completions based on language semantics and an analysis of your source code. If a language service knows possible completions, the IntelliSense suggestions will pop up as you type. If you continue typing characters, the list of members (variables, methods, etc.) is filtered to only include members containing your typed characters. Pressing Tab or Enter will insert the selected member.

You can trigger IntelliSense in any editor window by typing Ctrl+Space or by typing a trigger character (such as the dot character (.) in AL language). This time we just need to type Ctrl+Space at the location where the object ID is defined, and we can see the object ID prompt.

Test video: Very simple.

This requires enabling the following setting, “editor.suggest.showReferences”

And please note that this method does not check other extensions. If there are other third-party extensions in your environment and they use the same object range, the following error may occur.

Reason: ‘The application object of type ‘PageExtension’ with the ID ‘50100’ is defined in multiple apps. The apps are: BC26P by YUN ZHU 26.0.0.0; TestObjectId by Default Publisher 1.0.0.0.’

If you add the dependencies property and download the symbol file, this will not check for object IDs in other extensions.

Great. Give it a try!!!😁

PS:
1. If you want to view all object ids, you can refer to the following method.
Dynamics 365 Business Central: View the all object details (Type, ID, Name…) and find out what extension an object belong to without using VS Code

2. If you need more powerful features, you can try AL Object ID Ninja

3. Business Central 2024 wave 1 (BC24): Support for multiple extensions to same target and extensions and target in same app – Define extension objects in same app as their base object

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL