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)

Indexing a Data Entity with View as datasource

(1) ShareShare
ReportReport
Posted on by 3,542

A have a view with a union query as datasource. I didn't bother with the index, but now I created a Data Entity from the view, so I need an index. (As a side question: does the entityKey need to be unique? I assume so.)

Is there some documentation I can read or an example to look at?

My first solution was to save use the tableID and recID. But then those fields are included in the export - my boss got a heart attack.

My current solution is saving the SourceTable as an enum and then I have a Description255 field (lets name it sourceIndex) in which I build the index of the source table as a string. For example one of the query datasources is table PurchLine. So MyView.SourceTable = XYZSourceTable::PurchLine and MyView.sourceIndex = PurchLine.PurchId + int2str(PurchLine.LineNumber). Is this solution acceptable?

It still has issues though. Firstly I have no idea what the performance impact is of a Description255 string as part of index. And then one of the other source tables is BankAccountTrans. BankAccountTrans's only unique index and primary index is AcctTransDate which includes RecId. So the resulting string is not very flattering to say the least.

Edit note: I edited the Subject. And then if I may try to state the question better:

I have an entity with a view as datasource. The view is the result of a union query. An entity requires an index. What should I do to accomplish that? I mean a view from a union query has no logical index. A few suggested answers mentions that a view does not need an index (you actually get a BP violation if you do supply one). I did not know that until now, but nevertheless that is not the question. (Yes the subject was incorrectly described - my bad.) The entity needs an index, not the view.

Kind regards

Thanks for reading

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    István Orosz Profile Picture
    2,137 on at

    Hi,

    Not quite sure I understand what you mean indexing a view? It is generally not needed, you can find the necessary indexes on the tables. Or do you mean SQL level Indexed Views?

  • Pete Alberts Profile Picture
    3,542 on at

    I think you may have missed "...but now I created a Data Entity from the view..." A data entity needs an index, or at least I haven't been able to create one without an index. So it's the Data Entity for the view that needs the index. Which more-or-less means the view needs an index

  • Pete Alberts Profile Picture
    3,542 on at

    Thanks for the reply Crispin.

    Yes, that is correct.

  • Pete Alberts Profile Picture
    3,542 on at

    If it comes down to hiding fields on export, the solution will probably be in the page Martin has referenced me to thousands of times: docs.microsoft.com/.../office-integration-edit-excel (I still haven't spent enough time on it). Hiding the fields on a form is easy and then on export the solution should be in the mentioned page.

    But I would still like to know if it is "okay" to index with a large string as I mentioned in the OP.

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

    Hi,

    It is better to use the fileds PurchLine.PurchId and PurchLine.LineNumber add them together to an index without conversation.  Although you can create full text index in SQL, with converting LineNumber into string.

  • Pete Alberts Profile Picture
    3,542 on at

    I updated the question/post.

  • Verified answer
    Pete Alberts Profile Picture
    3,542 on at

    I discovered a decent solution just now.

    Open in Excel uses the AutoBrowse or AutoReport field group. (I was not aware of this simple fact, or maybe I just overlooked it. In any case, my apologies - I feel like I wasted your time.)

    In that context, for some future struggling soul like myself:

    Store ParentTableId and ParentRecId in the View. Pull them through to the Data Entity. This enables you to produce the required Unique Index for the Data Entity (I'm still unsure whether it needs to be unique). Finally just don't include the mentioned fields in the mentioned field groups (I'm not sure which field group is used for Open in Excel and I don't have the time to check, but it is one of them).

    Thank you all

  • Pete Alberts Profile Picture
    3,542 on at

    It's the AutoReport field group.

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