web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Macros & Const in AX7 / D365

dasdasd Profile Picture dasdasd 841
Macros can still be created in Dynamics 365 for Finance and Operations to store a value that will not be modified.  They are created in either a macro file or by using the pound define keyword.  So we can see that here with our either hash tag or pound define.  

However, there is a new modifier to create constant variables.  By placing the keyword const before a variable, it will create the value that cannot be modified.

Const allows you to define members on a class and variables in a method that can only be initialized during the declaration. Constant value must be known at compile time. Compiler will replace references to these constants with the literal value.

Const also replaces most use cases of macros.

Example code:













Key Benefits:
IntelliSense in the editor.
- Support for "Go to definition" in the editor.
- Full control of the type for the constant.
- Faster compilation – macros are notorious hard for the compiler to handle.
- None of the macro idiosyncrasies – like the ability to redefine/override.

Reference link: X++ in AX7: Const keyword

This was originally posted here.

Comments

*This post is locked for comments