Hi all.
I have an issue in Dynamics Ax that I could not set query on joined form data sources. I have to set the query so that I could get the query back to the former query before I add the link into the query. I have the requirement to remove only few links between query data sources. As I know, AX only has method to remove all the links with clearLinks(). So I have to be a little bit tricky by copy the query first into the temporary query before I start to add link into the query.
_queryTemp = new Query(purchLine1_ds.query());
So, when I want to remove that link, I only need to set the query with the temporary query that I have copied before.
PurchLine1_ds.query(new Query(_queryTemp));
I have successfully used this workaround several times. But, I just realized I can’t used this method anymore since the form datasource which I set the query is the joined datasource and it issued an error.
Is there any workaround or another method? Thanks.
Could we return back from details of your implementation to your actual requirement? Why are you removing links? Can’t you simply disable linked data sources? And what’s the problem with clearLinks()?
Thank you Martin for your response. The detail is here. I want to modify the PurchLineBackOrder form in AX 2012R3. I want to add the ItemBuyerGroupId and Department filter which both of them were in PurchTable and DefaultDimensionView. As long as the grid data source is InventTrans table and the form doesn’t have PurchTable and DefaultDimensionView as its data sources, I need to add link between the InventTrans and both of the tables when the I enter the filter. But when I clear the filter, I think I couldn’t simply just use clearLinks() because it will remove all of the links that were initialized in init() or other standard methods defined by AX in that form. So I try to get the query to temporary query before I add the link and when I clear the filter, I set the datasource query with that temporary query to generate the data fully without any links or filter.
-
Is there any method to clear the specific link with another table(not all of the links)?
-
Is there any method to set the query on joined form data source (if the datasource was not joined, this method is run smoothly)?
Thanks
Why don’t you merely remove the value of the filter?
Also, if you remove join conditions (= links) but you don’t remove joined data sources, you get cross-joins, won’t you? It doesn’t sound like what you wanted.
If removing the filter isn’t enough, disable data sources.
Yes, if you’re using QueryBuildRange, you can remove it by calling QueryBuildDataSource.clearRange(). Or you can keep it in place and allow all values, as explained before.
“Why do I have to disable the datasource since the grid was based on it?” - I mean the linked data sources.
“Where should I put the .addLink method correctly?” - I can’t answer it, because I don’t know what you’re doing with it. Maybe you should create links at design time, maybe when initializing the form, maybe when adding a specific filter…
“So, the AX doesn’t have a method to remove the specific link other than clearLinks()?” - No, but it’s not a big problem. You can remove all links and recreate those you need. Note that removing a link is not very common.
I already told you how to do it: disable the joined data source by calling enabled(false).
If you need any additional advice, please tell us what exactly your data sources and how they’re linked, what code you put into init() method etc. It will save time for both of us.
I said that “If removing the filter isn’t enough, disable data sources” in my second reply - if you told me that you don’t want to keep the data source enabled, I wouldn’t even suggested removing filters. And all the following discussion about filters wouldn’t happen if you realized that the condition (“If removing the filter isn’t enough”) is met in your particular case.