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 :
Microsoft Dynamics AX (Archived)

Conditional Join on select with macro

(0) ShareShare
ReportReport
Posted on by 1,535

Is it possible to write in X++ select with conditional join using macro ?


I want to write select like this:

variable1 = value from database;

while
select Table1
#if.VARIABLE1(...) join Table2 where Table1.Field1== Table2.Field1 #endif
{
        info(strFmt("%1 / %2", ....));
}

Ofcourse I can make query and write it with query = new query(....) but I have a lot places with code to change. My select is very complex (about 10-14 tables) and I thinking that is it possible to change it with macro. Conditional join depend on value from database (not from constant value !).

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,912 Most Valuable Professional on at

    Macros are interpreted at compile time, so forget reading conditions from database etc.

    If you have many places where to change the code, using a macro wouldn't change this fact. Refactor your code first to have a single place to change and than use the query class there.

  • Ireneusz Smaczny Profile Picture
    1,535 on at

    I was afraid that it would happen :-(

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans