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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to use Macro in AX 7

(0) ShareShare
ReportReport
Posted on by 4,131

Hi,

In AX 2012, if we use macro in the code, just declare #define in the beginning of the methods. How do we use Macro in AX 7 now?

Thanks,

*This post is locked for comments

I have the same question (0)
  • Verified answer
    krishna.rao@dax Profile Picture
    3,008 on at

    In AX7 X++ now supports the const keyword.

    It replaces most use cases of macros.

    Have a look here for more details

    blogs.msdn.microsoft.com/.../x-in-ax7-const-keyword

  • Verified answer
    Faisal Fareed Profile Picture
    10,796 User Group Leader on at

    Hi Yuji,

    In short, macros are now used as constants in D365O have a look on this post to see how you can use both.

    devserra.wordpress.com/.../macro-or-const-on-ax-7-what-use

  • Basheer17 Profile Picture
    2,720 on at

    You can use macros the same way we did it in AX 2012. However try to use "const", in some cases it's not possible. For instance

    #localMacro.DateFilter

           ((priceDiscTable.FromDate <= toDate || !toDate)

           && (priceDiscTable.ToDate >= fromDate || !priceDiscTable.ToDate))

       #endMacro

    In this case you can follow traditional approach.

  • André Arnaud de Calavon Profile Picture
    303,669 Super User 2026 Season 1 on at

    Hi Yuji,

    One small addition here: The use of macros was powerful to also reuse blocks of coding. At compilation the macro part will be inserted in the coding which takes additional compilation time. For this reason, try to avoid use of macros. Microsoft is aiming to get compilations as fast as possible. For this reason, it could be the case that macros will be depreciated in future, but I'm not sure about this.

  • Joris dG Profile Picture
    17,780 on at

    In addition to performance, macros break a lot of development tooling. If you use macros to insert code blocks, none of the dev tooling can see that code. So things like code upgrade tools, visual studio add-ins, and any future tooling can never understand the macros, since those tools work against code, and macros are not "resolved" (/replaced) until compilation.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    Take a look at the video from last years' AX technical conference about the new development environment, where we learned that Macros are Evil in AX 7.

    daxioms.blogspot.hu/.../ex-plus-plus-x-for-those-not-into_21.html

  • Faisal Fareed Profile Picture
    10,796 User Group Leader on at

    Vilmos Kintera Are you able to open this link to watch video - it's not working for me and I am getting error 

    An error occurred while processing your request.

    Reference #97.cf18ae8c.1490135816.7800529

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    I have checked the central site for conference contents:

    mbs.microsoft.com/.../IS_ConferencePresentationsVideos

    There is a note there saying they had to remove all videos, and it is available upon request by emailing adocs@microsoft.com

  • Faisal Fareed Profile Picture
    10,796 User Group Leader on at

    Thanks Vilmos

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans