web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How can I control the record that is exposed via OData

(1) ShareShare
ReportReport
Posted on by 134
Hi
 
For a customer We have developed a new data entity, the data entity is based on InventTable and then some custom virtual fields.
 
The entity is used to export data to a 3PL. In D365 we have a setup specifying that only items with specific properties or which is part of a specific ItemGroup should be exposed.
 
Using the $filter is not what the customer want as that will potential expose all items.
 
how can we apply the "filter" to the data entity so that only items which is allowed for the 3PL is exposed in the data entity ?
 
Thanks
Categories:
I have the same question (0)
  • Suggested answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi,
     
    If you have group field in the entity, you can add filter the exported data as below:
    https://X.XXX.dynamics.com/data/YourEntity?$filter=GroupField eq '3PL'
     

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue

  • steen.rabol Profile Picture
    134 on at
    No, the filter in the odata query is not the solution in this case, the customer only want to expose the items that is within the criterias of the setup
  • Suggested answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi,
     
    You can add range on the DataSource of your field in the data entity, make sure to add the range to Data source range not to data entity range.
     
     
     

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue

  • Saalim Ansari Profile Picture
    666 on at
    Hi,
     
    To restrict which records are exposed in your custom Data Entity in D365FO, especially when $filter is not acceptable (as it risks exposing all data), you need to apply a permanent filter on the entity itself by customizing its query or datasource.
  • steen.rabol Profile Picture
    134 on at
    Hi
     
    Yes, I would also think that I need to modify the query somehow, but when look ing at the available methods that one can override on the entity there is none that looks like it can do what I need.
     
    maybe initializeEntityDataSource() and then do not call super() ?

    or do you have an example?

    I would not like to have to go down the path to replicate inventtable to another table and then use that as datasource for the entity.

  • Raj Borad Profile Picture
    1,428 on at
    Hi Steen,
     
    You can try below x++ code in data entity query:

        Query q = super(_queryBuildDataSource);
        QueryBuildDataSource qbds = q.dataSourceTable(tableNum(InventTable));
        qbds.addRange(fieldNum(InventTable, ItemGroupId)).value(queryValue("3PLGroup")); // or use item properties
        return q;
     
     
    Avoid using 'initializeEntityDataSource()' to block super(), as that may cause unexpected behavior.
    I think using a query() is a clean, supported approach that ensures only permitted records are included at the source level, thus never exposed externally. May this approach aligns with security best practices for 3PL integration.
     
    Thanks, 
    Raj D Borad
  • Suggested answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
     
    Did you try to add the range to the Query without code? Can you share your entity data sources?
     
     

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue

  • steen.rabol Profile Picture
    134 on at
     
    Thanks for the suggestion, but in which method ?
     
    There is no query() method on the data entity
     
     
    As mention, it is a custom entity that is based on Inventtable, there is a dynamic setup, so using ranges will not work
     
    there is not so much to share, you can simply create a new Data entity, then select Inventtable as base table select 2-3 fields and that's it, as mentioned, the data entity will be used by 3PL to get the list of released items, but the customer does not want all items to be exposed, so therefor there is a setup table where there can be one or more item groups that should be exposed to the data entity
  • Suggested answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi,
     
    You can try to use QueryRangeFunctionAttribute to add dynamic range as in the below link:
     
     

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue

  • Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
     
    Did you try my last suggestion?
     
     
    Thanks,
    Waed Ayyad

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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans