Microsoft_MVP_banner

Filter datasources of same table on Tab Pages

I had a requirement to show the filtered data of one table on different tabs within a form. The standard filter functionality in AX forms is a powerful feature. Using this filter functionality in your code is something you’ll definitely use at some point in time as a programmer.
Let me explain it with an example; we have a currency table with multiple currencies e.g. EUR and USD. I have two different tabs named ‘EUR’ and ‘USD’ and these will show the respective filtered data from the currency table i.e. EUR tab will show the EUR currency and USD will show the USD currency data.
Add two datasources (CurrencyEUR and CurrencyUSD) on the form of the same table (Currency), after assigning these datasources to the tabpages. You just need to follow the following 3 steps.
Step 1: Declare a class variable
In the ClassDeclaration method of the form, define a range.
QueryBuildRange CurrencyQBREUR;
QueryBuildRange CurrencyQBRUSD;

Step 2: Instantiate the new range.
In the init() method on the datasource of the form, you assign the range to a specific field (after the super call).

DataSource: CurrencyEUR
public void init()
{
super();

CurrencyQBREUR = this.query().dataSourceName(‘Currency’).addRange(fieldnum(Currency, CurrencyCode));
}

DataSource: CurrencyUSD
public void init()
{
super();

CurrencyQBRUSD = this.query().dataSourceName(‘Currency’).addRange(fieldnum(Currency, CurrencyCode));
}


Step 3: In the last step, you assign a value to the range.
This is done in the executeQuery method on the same datasource of the form. Before the super call. Like this:

DataSource: CurrencyEURpublic void executeQuery()
{ ;

CurrencyQBREUR.value(queryvalue(‘EUR’));

super();
}

DataSource: CurrencyUSDpublic void executeQuery()
{ ;

CurrencyQBRUSD.value(queryvalue(‘USD’));

super();
}

This can be done in one line of code as well. In the init() method of the form datasource, after the super call, place this code:
this.query().dataSourceName(‘Currency’).addRange(fieldnum(‘Currency’,CurrencyCode)).value(queryvalue(‘USD’));

But this way, it’s fixed. If you choose the 3 step method, you could for example use a variable in the range value. The way to go would be to place an input field on your form. Get the value from it and supply it in the executeQuery() method.

For example like this:
public void executeQuery()
{ ;
CurrencyQBRUSD.value(queryvalue(MyInputField.text()));
super();
}

Just make sure the executeQuery method is executed, thus applying the desired filter (maybe be using a button on your form to activate it).

Share:

Related Posts

Microsoft Copilot
admin

Exploring Microsoft Copilot Architecture

Microsoft Copilot isn’t just another AI tool; it’s a comprehensive platform designed to be your indispensable companion, enhancing productivity, fostering creativity, and facilitating information comprehension all through a user-friendly chat interface. The concept of Copilot emerged two years ago when Microsoft introduced GitHub Copilot, aiming to assist developers in writing

Read More »
How to enable new Microsoft teams - Public Preview!
Microsoft Teams
Faisal Fareed

How to enable new Microsoft teams – Public Preview!

New Microsoft Teams is just AWESOME, quick but useful post below shows how you have this preview feature to make your life EASY!  Open Microsoft Teams admin center [Ask admin in your organization if you don’t have access] and follow path Teams > Teams update policies > Click on an existing

Read More »

Send Us A Message

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Post

Exploring Microsoft Copilot Architecture

Exploring Microsoft Copilot Architecture

Microsoft Copilot isn’t just another AI tool; it’s a comprehensive platform designed to be your indispensable companion, enhancing productivity, fostering creativity, and facilitating information comprehension all through a user-friendly chat interface. The concept of Copilot emerged two years ago when Microsoft introduced GitHub Copilot, aiming to assist developers in writing…

How to enable new Microsoft teams – Public Preview!

How to enable new Microsoft teams – Public Preview!

New Microsoft Teams is just AWESOME, quick but useful post below shows how you have this preview feature to make your life EASY!  Open Microsoft Teams admin center [Ask admin in your organization if you don’t have access] and follow path Teams > Teams update policies > Click on an existing…

Electronic Reporting: Send vendor payments to external azure storage via X++

Electronic Reporting: Send vendor payments to external azure storage via X++

Electronic Reporting module in Microsoft Dynamics 365 Finance Operation lets you archive file generated by ER at SharePoint location and in Azure Storage as per this link Archive ER destination type – Finance & Operations | Dynamics 365 | Microsoft Learn. APIs can be used to check message status and read…

FaisalFareed@2025. All rights reserved

Design by T3chDesigns