AX – D365FO – Create an AOT Macro #D365FO

You can organize the constants used in your code by creating a macro in the AOT for keeping all your constants in one place.

Also is a good idea if your macro is going to be used in several places so you will be able to reuse the macro.
To create a new macro in the AOT:

1.       Click “Add” and “New Item”

2.      Choose “macro” and call it “MyMacro”

3.      Now insert the list of your macro inside the code like shown below)


4.      Save the Macro, and it is ready to use.

To use the macro created in the AOT the macro command #macrolib is used.

Here the AOT macro is name MyMacro, and it can be used in the code as shown below.

static void testMacro(Args _args)
   str test1, test2;

   #macrolib.MyMacro       //Declare the global Macro
   test1 = #productCollection   //Use the macro value defined inside
   test2 = #export //Use the macro value defined inside

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s