Notifications
Announcements
No record found.
Hi ,
I am new to AX 2012 . I am having one Form and there i have 2 Grid controls. In First grid i have Item Group. In the second grid i have fields like ItemNo, and Product name. If i select one Item Group in first grid , the second grid should be populated with the ItemNo and Product Name which is assigned with that Item Group. Help me on this.
Regards,
Ram.
Hi Ram,
You should be able to accomplish this using the datasource joins. You can look at InventTransferOrders form as an example.
So basically you first grid has Item groups and second grid has Items. And when you select an Item group, you want to filter the second grid, showing only items of that Item group. I assume that your data source tables are ItemGroup and InventTable.
In most cases, such filtering should happen automatically based on table relations and form data source properties. But in case of Item group, InventTable is not directly related to ItemGroup, instead the relation goes through InventItemGroupItem. One item can be in many item groups.
So, you need to add some code, which should be triggered in the active method of your ItemGroup data source. There you need to add code that re-executes the InventTable data source query, filtering only the relevant records.
Here's some example on how to define ranges in executeQuery method of a form data source: community.dynamics.com/.../699211
Hi Ram Kumar,
If the Product Name field is display method, you could call it in datasource field(ItemNo) modified():
public void modified() { table_ds.cacheCalculateMethod(tableMethodStr(tableName,MethodName)); super(); }
If not, you just have to fill the Product Name field by its value in the modified() method.
Hi Nikolaos,
Could you please give me some code samples to get the active record value of one grid and accessing that in an another grid. I am new to AX.
Ram
You can get the active record of a data source simply by referring to the data source name.
For example if your data source name is ItemGroup, then you can type ItemGroup to access that table buffer.
And you can type ItemGroup.ItemGroupId to get value of ItemGroupId.
So, you need two parts:
1) In active method of ItemGroup data source, call executeQuery of InventTable data source
2) In executeQuery method if InventTable data source, use ItemGroup.ItemGroupId to filter the values.
Here is my form. Here the Itemgroup grid's stringedit control datasource is InventItemGroup. On the right hand side the Itemgroup datasource is InventItemGroupitem datasource and Invemttable datasource for Itemid. If i select Audio in the left hand side the grid on the right hand side should be filtered based on the Audio itemgroup. I dont know how to and where to write the code since i am new to ax 2012. Help me on this. I need some code samples to do this
Thanks & Regards,
If you read my previous replies, you should know following details:
1) Where to write code
2) How to fetch the selected ItemGroupId
3) How to filter a data source (in this case InventTable) in x++
Could you try to describe what you learnt so far from the replies and suggestions, and what kind of code you tried to write?
// Datasource- Inventitemgroupitem public void executeQuery() { QueryBuildRange qbr; this.query().dataSourceTable(tableNum(InventItemGroupitem)).addRange(fieldNum(InventItemGroupitem, ItemGroupId)).value(queryValue(InventItemGroup.ItemGroupId)); super(); } // Datasource- Inventitemgroup public void selectionChanged() { super(); if (inventItemGroup.ItemGroupId) { inventItemGroupitem_ds.executeQuery(); } }
I have set the datasource property for my second as inventitemgroupitem. Here is my code for execute query in Inventitemgroupitem. I have marked breakpoint for selection change method in Inventitemgroup (First grid) it triggers whenever i selecting. and also i marked another breakpoint in execute query . the value for the range is what itemgroup i was selected in the first grid , is applied to the query but my second grid is not filtered. If my code was wrong correct me on this.
Ahh, so your data sources are InventItemGroup and InventItemGroupItem! I thought that they are InventItemGroup and InventTable.
In this case you don't need any x++ code to achieve the filtering.
Just set JoinSource of InventItemGroupItem data source to point in InventItemGroup data source, and try to set Link type to Delayed. Does it work?
Whenever you have two tables that are directly related to each other, you don't need any x++ development to handle the filtering.
I tried what you have said, It works .
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 451 Most Valuable Professional
André Arnaud de Cal... 428 Super User 2025 Season 2
BillurSamdancioglu 239 Most Valuable Professional