Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

AX2012 C# Interop code similar to FieldNum in X++

(0) ShareShare
ReportReport
Posted on by 215

I have some code in X++ that looks like this: `fieldNum(InventDim, configId)`

 

I need to duplicate this code in C# for an AX2012 Interop program.  I need to do this becuase I need to call the method

 

 `EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(FieldId _inventDimFieldId)`

 

I know how to make the call in C# but I am completely unsure how to get the FieldId.  I did find an article http://msdn.microsoft.com/en-us/library/cc616802.aspx that discusses using the  dll Microsoft.Dynamics.AX.Framework.Services.Client to get access to those specific methods but my AX2012 Environment has no DLL file named Microsoft.Dynamics.AX.Framework.Services.Client.  Is there some other way to call the above method or a different call to get access to the FieldId?

*This post is locked for comments

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,445 Most Valuable Professional on at
    Re: AX2012 C# Interop code similar to FieldNum in X++

    TableDataFieldMetadata  is indeed in Microsoft.Dynamics.AX.Framework.Services.Client namespace, but in Microsoft.Dynamics.Framework.Metadata.AX assembly (can be found in GAC).

    Just for information:

    fieldName2Id() is a system method (in AOT under System Documentation > Functions), but you could easily write your own wrapper method in a custom class.

    Joris also suggested SysDictField class - you could use factory methods newName() or findFieldByName() and id() to get the value.

  • Ben Hoffman Profile Picture
    Ben Hoffman 215 on at
    Re: AX2012 C# Interop code similar to FieldNum in X++

    So then how do I call methods in .NET that require FieldIds?  There must be a way.  I looked for the FieldName2Id method and found it only in the AifUtil class which states it should only be used my Microsoft internally.

  • Verified answer
    Joris dG Profile Picture
    Joris dG 17,775 on at
    Re: AX2012 C# Interop code similar to FieldNum in X++

    You have to remember fieldNum is actually a pre-compiler instruction that translates that field name into a field ID in the actual compiled x++ code. That doesn't quite exist from the .NET end.

    What you can do however is use fieldName2Id, which I believe is a function on the global class or perhaps a static method on dicttable/sysdicttable or dictfield.

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans