Notifications
Announcements
No record found.
Hi
How can I modify the query of a view ?
Problem:
I need to expose data to an external app so I have created a view
Inventtable and then join InventItemInventSetup
I only want the record from InventItemInventSetup where invnetdimid is equal InventDim::inventDimIdBlank()
Any hints?
Thanks
You can define such fixed ranges in the query's data source properties, in Ranges node. Just add a range with value "AllBlank". No x++ needed.
If you want to add ranges in runtime, please share more information about how you expose this view to your external app.
One way of adding this range in x++ is to use a select statement (select * from myView where myView.InventDimId == 'AllBlank').
Sorry, but AllBlank is not working
AllBlank was for Ax2012, in D365 you can have Ax#1, Ax#2 Ax#3
which is why I have to find the 'correct' using the InventDimGlobal::inventDimIdBlank(); function
Ok, then you need to define the range during runtime.
Then it's like:
InventDimId myBlank = InventDimGlobal::invntDimIdBlank(); select myInventDimView where myInventDimView.InventDimId == myBlank;
As said, Im using the view to expose data so I do not use x++
I create a DataEntity based on the view and then it is exposed via OData
and yes, I would love to define the range at runtime, but in the 'code' for the View, I cannot get the query as the view extends 'Common' which is a 'Table'
Ok so the actual question is: is it possible to filter data entity somehow during runtime, when called via OData? And if it is, how to do it.
No, that is not the question, because in this case, the receiveng app cannot filter which is why the view needs to deliver the excact data
I did not say who should do the filtering, it might as well happen inside D365.
yes, and the normal way is to add a range and a value, but in theis case the value is not 'fixed'
Anyway, View is actually something that is synced to the database from D365. Same applies to data entities. Since the information about "blank" InventDimId must be fetched using x++ logic, this filter can't be present in the definition of the view or the data entity. Hence it must be filtered somehow in runtime.
Perhaps you could develop an OData action that finds out the "blank" inventDimId and writes it to a new table (that contains only this one field and always only one record). Then your entity could have exist join relation to that table, and this way the filtering would work. Not the most elegant solution, I know. But it would work.
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 592 Most Valuable Professional
André Arnaud de Cal... 478 Super User 2025 Season 2
BillurSamdancioglu 305 Most Valuable Professional