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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

how to create the related field fixed relation in query object in x++ code?

(0) ShareShare
ReportReport
Posted on by

how to create the related field fixed relation in query object(through addlink() method) in X++ code?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    DavidGunawan Profile Picture
    1,381 on at
    RE: how to create the related field fixed relation in query object in x++ code?

    Hi Kavitha,

    I think your objective can be achieved by add range in the query. So it will possible to has a filter and give the same results with field fixed relation.

    Do you need some example?

  • Community Member Profile Picture
    on at
    RE: how to create the related field fixed relation in query object in x++ code?

    Hi DavidGunawan,

    Kindly give example in X++ code to explain the field fixed relation in query objects.

  • DavidGunawan Profile Picture
    1,381 on at
    RE: how to create the related field fixed relation in query object in x++ code?

    Please find the example:

    static void testQuery()

    {

       Query q;

       QueryRun qr;

       QueryBuildDataSource qbd;

       QueryBuildDataSource qbd2;

       QueryBuildRange qbr;

       //Define query

       q = new Query();

       qbd = q.addDataSource(TableNum(InventTable));

       //Join with other table (InventSum)

       qbd2 = qbd.addDataSource(tableNum(InventSum));

       qbd.relations(true);

       qbd.joinMode(JoinMode::InnerJoin);

       //Add range, this will act similar like filed fixed relation

       qbr = qbd.addRange(FieldNum(InventTable, ItemType));

       qbr.value(SysQuery::value(enums2str(ItemType::Item)));

       qr = new QueryRun(q);

       qr.prompt();

       pause;

    }

  • DavidGunawan Profile Picture
    1,381 on at
    RE: how to create the related field fixed relation in query object in x++ code?

    Hi Kavitha,

    Have you solved this issue? If yes, please flag this question as solved. So it will help others. Thank you.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#3
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans