Personalized Community is here!
Quickly customize your community to find the content you seek.
Have questions on moving to the cloud? Visit the Dynamics 365 Migration Community today! Microsoft’s extensive network of Dynamics AX and Dynamics CRM experts can help.
2021 Release Wave 1Discover the latest updates and new features to Dynamics 365 planned April 2021 through September 2021.
Release overview guides and videos Release Plan | Preview 2021 Release Wave 1 Timeline
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All TechTalks
Hi everyone. I do have a big problem finding how to resolve this situation. First of all I have to explain that I'm a begginer with Dynamics AX.
This is the thing:
I have a form with a lot datasources, the principal is Principal_DataSource, and we have a Second_DataSource.
I have a filer option for the data in the grid. This filter filters the content of Principal_DataSource when Second_DataSource.value3 == combobox.valuStr(); The linktype of Second_DataSource with Principal_DataSource is Delayed.
I'm getting crazy because a see in he forum a lot options like this inside executequery of Principal_DataSource :
qb = this.query().dataSourceTable(tableNum(Principal_DataSource)).addDataSource(tableNum(Second_DataSource)); qb.joinMode(JoinMode::InnerJoin); qb.addLink(fieldNum(Principal_DataSource, value1),fieldNum(Second_DataSource, value1));
But when I do it It doesn`t work at all. After that I have to put 2 addRange, so Its a bit crazy, and ofcourse I don`t know how to delete the source Second_DataSource to Principal_DataSource when this filter is disabled.
Other option that i was thinking about It's to use Principal_DataSource_ds.filter() but I don´t know how to filter ds with a query.
Thank You for your help.
A delayed link doesn't allow you to filter the parent data source. If you need both a filter and a delayed link, you indeed need two data sources. The best type of join would be Exists join, because you use it just for filtering and you don't need to fetch any fields.
Adding the data source at runtime is possible; just make sure you don't add it more than once. If you call addDataSource() every time the query gets executed, you can soon end up with many data sources. Another (and easier) approach is adding a third data source in form's definition. By the way, if there is a relation between data sources, you could simply use qb.relations(true) instead of addLink().
Make sure you're adding the range to the right data source. If something doesn't work, look at the actual database query used by the form. Again, don't add it more than once.
When you want to remove the filter, either set the range value SysQuery::valueUnlimited(), or disable the query data source (using QueryBuildDataSource.enabled() method).
Thank you for the answer.
I have a principal grid where appear all the requests for a service, so if a change the join type between this 2 data sources, in the grid will not appear all the requests, there will appear what a I need todo only when I active the filter.
This second data source It's the info about all the requests that have incidences. I have a tab where appears the incidences too, so that's why i have a delayed link, because I want to show the incidences only when the selected record have any incidence.
When I active the filter option, in the grid (only when I filter) must be appear the requests that have incidences. When I deactive the filter, in he grid have to appear again the previous data.
I have like 19 data source in the form related with Principal_DataSource , because i have a lot of tabs with info about, client, request, documents... So If I do like you said and put another data source, I supose that I have to add a copy of all data sources. Maybe I'm wrong It's what i understand.
I think the easier way must be filtering Principal_DataSource_ds, with "select Second_DataSource.value1 from Second_DataSource where Second_DataSource.value3 == "xyz" " and when I deactive the filter I only have to delete filter or recharge the info. But again, I don´t know how to filter a ds with query records.
Sorry, I must have explained something in a wrong way. Let me address the filter once more.
You can't use your current Second_DataSource to filter Principal_DataSource, because of the Deplayed link. But you want to do that, therefore you need one more data source. One DS for Second_DataSource table is the only your already have. And you'll add one more DS for the same table, as ExistsJoin, and add a range to this data source.
There is no reason to duplicate your 19 data sources; what we're doing here is just adding the one data source that you'll use for filtering of Principal_DataSource.
Thank you again.
I realizes later abou this. The point It's that If make the relations from the init the grid appears filtered:
Table2 joinSource table1 linktype delayed
Table2Copy joinSource table1 linktype existsjoin
Can I change the joinSource of table2copy whenever I want? Can I put Null joinsource I when i need to filter add table1?
Or active and deactive the relations whenever I want?
No, you can't change JoinSource. As I suggested in the last sentence of my first reply, you can disable the query data source by enabled() function. For example: Table2Copy_ds.queryBuildDataSource().enabled(false).
Alternatively you could change the type of join (e.g. to outer join), but it sounds inefficient.
Thank you very much. I made a mistake and I put another option instead of enabled. And I had the executequery of table1 before this instead of after.
Hi Martin Dráb.
With this option I realized that when you push the save button from froms toolbar, It throws a warning message, telling to introduce same field values. When I didn´t have these 2 tables and the realtion created, It worked fine. Any idea how to avoid this?
Thank you very much.
I found another way to make this work without any issue, or creating tables second data source...
Inside form classDeclaration create: query tableQuery;
Inside form init: tableQuery = firstTable.query();
Inside form datasource firstTable.executeQuery():
this.query(new Query(tableQuery ));
This way you can add datasources and joins and whatever you want.
Business Applications communities