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 :
Microsoft Dynamics AX (Archived)

Filter a view

(1) ShareShare
ReportReport
Posted on by 3,542

In context of my previous post: https://community.dynamics.com/ax/f/33/p/291428/836431#836431 (Not very relevant.)

I have a Data Entity with a View as datasource. The view has a Union Query as datasource. I use the entity to export to Excel. All in working order.

I now need to apply filters to the export. The filters should not be visible to the user and need to applied at runtime.

I have limited experience with Data Entities and Views, thus I don't know where to start looking for the solution.

I would be glad if someone could point me in a direction.

Thanks for reading

*This post is locked for comments

I have the same question (0)
  • Pete Alberts Profile Picture
    3,542 on at

    In short: I don't know where to apply the filters.

  • István Orosz Profile Picture
    2,137 on at

    Hi,

    You can apply your filter as a range to the query datasource. Is that what you looked for?

    http://www.axaptapedia.com/Expressions_in_query_ranges

  • Pete Alberts Profile Picture
    3,542 on at

    Thank you very much Istvan and Crispin.

    I'm fine with queries. But then I still have the issue of "where".

    If my question seems vague: For example I know that to override a form datasource field lookup I build a query and call sysTableLookup.parmQuery(myQuery);;;;; for a form datasource I can filter its values by building a query and call tableA_ds.query(myQuery).

    Where or how do I "send" the query to the view?

    I have tried a few things:

    1) For a variable of the view: I couldn't find a method that looks like the solution

    2) For a DictView variable: I couldn't find a method that looks like the solution

  • Pete Alberts Profile Picture
    3,542 on at

    And I suspect filtering the View's query will not be sufficient.

    I think it might have to be done on the entity, because I doubt the ranges will be "remembered" when the entity is refreshed in Excel...

  • István Orosz Profile Picture
    2,137 on at

    Hi,

    It is D365 topic from the header, so do not use overriding - instead go for extensions (or CoC/event handlers). What is your process of exporting to Excel please?

  • Pete Alberts Profile Picture
    3,542 on at

    I don't understand the first part of your sentence, would you mind explaining please.

    My method of exporting is by a Data Entity.

    This is standard if I understand correctly... Here is my understanding/description of the process: I display the view (currently without required ranges) on a form. AX automatically picks up the entity I created for the view. So when the user clicks "Open in Microsoft Office" everything is done for me. The view data is exported and it is somehow linked so that if the user refreshes in Excel any new records are also fetched and the excel data is updated.

  • Verified answer
    Martin Dráb Profile Picture
    237,967 Most Valuable Professional on at

    If you use "Open in Office" (not "Export to Office"), Excel (with help of the Data Connector add-in) will get data from data entities exposed through OData services. That's how it's "linked".

    Now the question is whether you want to always applies the filter for this entity. If so, simply change the entity. If not, let's analyze your requirements. There are options such as templates or even custom code. If you want, you can explore Create Open in Excel experiences page in documentation.

  • István Orosz Profile Picture
    2,137 on at

    Hi Pete,

    For the first part of my sentence:  dynamics365/unified-operations/dev-itpro/extensibility/migrate-overlayer-extension

    Everything else was described by Martin.

  • Pete Alberts Profile Picture
    3,542 on at

    Thanks Martin

    Yes, I meant "Open in Office". I'm embarrassed to say I have not read the page you specified - will do that now.

    I have both types of filters - the filters that should always be there I simply hardcoded (and locked them) into my AOT query (which I assume is acceptable) and then there are filters that depend on some user input. I guess that will be answered by the link you provided. Will get back shortly.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans