Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Data entity key field code-level identification

Posted on by 32

Hi.

Could I ask for help in finding any clue (if possible) about the way to identify which of the specific data entity fields are defined as its key fields?

Using the idea found in the following post  https://metadataofdataentityinax7.blogspot.com/ I was able to fetch data entity specification and prepare it in JSON-like format requested by the customer, however I couldn't find a way to accomplish the above.

Or maybe there is a system built-in way to extract given data entity's schema in any possible format?

Thanks in advance for any help on this.

Kind regards,

Tomek.

  • tgudwanski Profile Picture
    tgudwanski 32 on at
    RE: Data entity key field code-level identification

    Great thanks Martin for your prompt answer!

    I've managed to check it and it works perfectly. Seems to be a good tool, much more accurate than using Dict* classes in this case.

    Wish you all the best :)

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: Data entity key field code-level identification

    You can extract this information from the new metadata API that was introduced in AX 7.

    Here is an example:

    Microsoft.Dynamics.AX.Metadata.MetaModel.AxDataEntityView entity;
    entity = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetDataEntityView("HcmEmployeeEntity");
            
    var key = entity.Keys.get_Item(entity.PrimaryKey);
    System.Collections.IEnumerator enumerator = key.Fields.GetEnumerator();
    while (enumerator.MoveNext())
    {
        Microsoft.Dynamics.AX.Metadata.MetaModel.AxDataEntityViewKeyField field = enumerator.Current;
        info(field.Name);
    }

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans