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)

Filtering Form Datasource Results

(0) ShareShare
ReportReport
Posted on by

Hi Everyone,

   I have 2 datasources "A"(parent) and "B"(Child) on Fom.

on datasource "B" -> joinSource ist set to "A", and  linkType = InnerJoin.

I want to filter the results of datasource "B" . I have tried executeQuery method on "B" but its not working.

The problem is due to the inner join some records on "B" are displayed that i do not want to be shown.

Can anyone please help.

Thanks in Advance.

Bests

 Shah

*This post is locked for comments

I have the same question (0)
  • AX 2012 r3 Profile Picture
    2,426 on at

    Hi,

    Try Writing your Unnecessary B Records  before super call of B Datasource ExecuteQuery()

    public void executeQuery()

    {

       ;

       GroupHeader_ds.query().dataSourceTable(tableNum(GroupHeader)).clearRanges();

       if(statusFilter.valueStr() == enum2str(AllDraftPosted::Draft))  

    {    GroupHeader_ds.query().dataSourceTable(tableNum(GroupHeader)).addRange(fieldnum(GroupHeader,Status)).value(sysquery::value(GroupStatus::Draft));

      }

       super();

    }

  • Community Member Profile Picture
    on at

    Hi,

     Thanks for your reply, but there is a inner join on Datasource B. and using executeQuey does not get called when the data is called and shown on the listpage.

    I have tried using query range before and after super but nothing happens.

  • Martin Dráb Profile Picture
    239,213 Most Valuable Professional on at

    List pages are based on AOT queries. Can't you simply add your range there?

  • Community Member Profile Picture
    on at

    No, setting range on the query will not give the appropriate results.

    In datasource "A" (temporary table) records are written then it is linked to "B" where  inner join is performed on ID , but there are some other conditions that i need to check, and only those records should be shown that fullfill the condition in B.  

  • Martin Dráb Profile Picture
    239,213 Most Valuable Professional on at

    You filter data by setting ranges to the query. If you say that your requirement can't be done by that, you have to change the design.

    Or did you mean that you can't add the ranges to AOT but you can add them at runtime?

  • Community Member Profile Picture
    on at

    Well, From datasource B i want to get the highest count record example

    Datasource A    ,       DatasourceB ( joineSource = A,  linkType = innerJoin)

    A -> Id = 1      B -> Id = 1 , Count =  2

                            B -> Id = 1 , Count =  3

                            B -> Id = 1 , Count =  1

    so i want to get the row from B , where Count is higest(meaning = 3)

    so only B-> Id = 1, Count = 3 (record) should be displayed on list page.

  • Martin Dráb Profile Picture
    239,213 Most Valuable Professional on at

    Okay, I see. Please make sure next time that you explain your problem properly, saying "I want to filter the results of datasource "B" . I have tried executeQuery method on "B" but its not working." is clearly something else.

    If your intention is getting only B-> Id = 1, Count = 3, the right query should be this:

    select count(RecId) from B
        group by Id


    Model it as an AOT query and use it in your form.

  • Community Member Profile Picture
    on at

    No, Sorry i think you got it wrong :) .

    Id and Count are fields in Datasource B.  Now Count can be any number from 1 to N . so want to show only that record from B where Id = 1 and Count = MAX .  so there can be many records with id =  1 in B  and all have some "Count" value. so i need to display only that record from B where Id = 1 but Count = MAX (Max value from Count Field) .  ( 1, 2 ,3 ... 10) so Count = MAX, which is (10)

  • Community Member Profile Picture
    on at

    And also execute method is not working on Datasource B. maybe cuz of Innerjoin.

    So how will it work.

  • Suggested answer
    Martin Dráb Profile Picture
    239,213 Most Valuable Professional on at

    Aha, so "count record" means "the highest value in the Count field" (ignoring the fact that it can't be called Count, because that's a keyword in X++), you actually wanted to ask how to join a single record only (selected by some rule, in your case the one with the highest count) and the whole discussion about filtering and executeQuery() is not relevant to your problem at all.

    You're lucky, because I have a blog post describing exactly this scenario: Join first line in AX 2012. Just don't forget to take into account Partition and DataAreaId; I've omitted them to keep things simple and some readers were confused by that.

    executeQuery() works exactly as it should. You can't expect it to execute twice, once for each datasource, because there is just a single query to run in your case.

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 16

#2
GiacomoRovai Profile Picture

GiacomoRovai 4

#3
Douglas Noel Profile Picture

Douglas Noel 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans