Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Adding two datasources for different tables to same query object for a SysQueryForm

Posted on by Microsoft Employee

Hi

A sysQueryForm is not filtering by a field correctly. This field is from a different table that has been joined after modifying the sysquery.

How to add two different tables as a data source of a query object and filter by the field of the joined table on a sys query form?

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Adding two datasources for different tables to same query object for a SysQueryForm

    Thanks for the response. The issue was resolved using the SysQuery:findOrCreateRange method.

  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    RE: Adding two datasources for different tables to same query object for a SysQueryForm

    Can you show us your complete code? And if it's not visible in your code, please tell us what datasource exist in the query.

    For example, I wonder why you search for a ProjPostedTransTable datasource if you've just created it.

    If there is no other datasource for ProjPostedTransTable, then you can simply refer to qbdsProjPostedTrans variable. And you can throw away all the code dealing with ranges, because there are no ranges to iterate. You would have to add some first, which you didn't. If you want to add some ranges, you'll have to fix your logic.

    Or your query already contains another DS for ProjPostedTransTable and your code may be filtering the other DS (which you didn't even mention so far).

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Adding two datasources for different tables to same query object for a SysQueryForm

    Thanks for the quick response! Hmm I tried the above but it doesn't output any records in the table though the table contains records with the matching category id. Not sure why its not outputting any record. Hope to hear from you soon.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Adding two datasources for different tables to same query object for a SysQueryForm

    Hmm I tried the above but it doesn't output any records in the table though the table contains records with the matching category id. Not sure why its not outputting any record. Hope to hear from you soon.

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: Adding two datasources for different tables to same query object for a SysQueryForm

    Hi !

    If you want to join ProjPostedTransTable to ProjTable you should add new DS to qbdsProject instead of _qbdsHeader.

    qbdsProjPostedTrans = qbdsProject.addDataSource(tableNum(ProjPostedTransTable));

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans