Announcements
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
Ok, that's fine I did not know that the query is only used to generate the view
I'll do the debugging tomorrow and get back with the details
All right, let's answer it: The query is used only on synchronization to generate T-SQL code defining the view in database. At runtime, you get data returned from the view in database; the original query isn't used at all and therefore any attempt to do anything with it is futile.
If you're now willing to look for something that can be done, could you give me a favour and debug the code to see where "Ax1" value is coming from?
When you know the pattern, such as that all IDs you're interested in starts with "Ax", filtering the data isn't difficult.
and the question is not wether the default dimid is 'AllBlank' or not, the question is about how to access the query of a view by code :)
Hi
I completly agree - according to the code it looks like it would be 'AllBlank'
We are woking on a upgrade from AX4 to D365
in SQL:
select * from INVENTDIM where inventdim.INVENTDIMID like 'a%' and DATAAREAID = 'dis'
Gives me 4 rows (i just show invnetdimid here)
Ax#1
Ax#2
Ax#3
Ax1
InventDimGlobal::inventDimIdBlank() return Ax1
So.... I'm as sure as I can be
Are you sure that blank dimensions IDs can be something like Ax#1?
When I'm looking into InventDim::findOrCreateBlank() (which is what actually does the job, InventDimGlobal::inventDimIdBlank() only adds caching), I see that the dimension ID is either 'AllBlank' or 'AllBlank2'.
static public InventDim findOrCreateBlank() { #define.blank('AllBlank') InventDim inventDim; InventDim inventDimAllBlank; InventDimId inventDimIdBlank = #blank; Counter logCount; inventDim = InventDim::find(inventDimIdBlank); if (inventDim.RecId && InventDim::isInventDimEqual(inventDim, inventDimAllBlank)) { return inventDim; } if (inventDim.RecId) { inventDimIdBlank = '2'; } ... }
Am I missing something?
For the record, my application version is 1.0.0.6.
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.
yes, and the normal way is to add a range and a value, but in theis case the value is not 'fixed'
I did not say who should do the filtering, it might as well happen inside D365.
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
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,186 Super User 2024 Season 2
Martin Dráb 227,996 Super User 2024 Season 2
nmaenpaa 101,148