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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

X++ in SysDictClass

(0) ShareShare
ReportReport
Posted on by 13

 SysDictClass dictClass =  SysDictClass::newName(classStr(LeaveRequestContract));
DataMemberAttribute attribute = dictClass.getAttribute(classStr(DataMemberAttribute)) ;

Info(strFmt("%1", attribute.Name()));

how to get the label name using datamemberattribute in contact class in x .I have tried the code above mentioned but I am getting the error "Object not set an instance of object".

Any other way or code to achieve this.

Thanks in advance,

Lakshmi.

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    238,743 Most Valuable Professional on at

    You should have debugged your code to understand where it fails.

    I think that that you have null in attribute variable. Then you're trying to call name() method of null, which can't work and it leads to 'Object not set an instance of object' error.

    The class surely isn't decorated with DataMemberAttribute. That's used for methods, not for classes.

  • Lakshmi Profile Picture
    13 on at

    Hi Martin,

    Thanks for your reply.

    Yah, I have done debugging you said correct Martin.

    My requirement is getting the parameter label name for example I  am having the parameter RequestDate in my contract, I need to get the Request date label name like Request date through x coding

    Example code,

    [ DataMemberAttribute('RequestDate')]
    public TransDate parmRequestdate(TransDate _requestdate = requestdate)
    {
    requestdate = _requestdate;
    
    return requestdate;
    }

  • Martin Dráb Profile Picture
    238,743 Most Valuable Professional on at

    As I said, this is an attribute for a method. You code is getting an attribute associated with the class header, not with a method.

    Also, what is your business scenario? For example, if you need this information in a UI builder class, you should be able to simply use what the system loads automatically for you.

  • Lakshmi Profile Picture
    13 on at

    My  goal is getting the list of parm fields label name to get in to the lookup. Now I can show parm fields labels only. Instead of parm fields I want pam label name to show in lookup. How we can achieve this.  

  • Martin Dráb Profile Picture
    238,743 Most Valuable Professional on at

    DataMemberAttribute doesn't contain any information about labels. Labels are taken either from the EDT returned by the method, or from SysOperationLabelAttribute.

  • Lakshmi Profile Picture
    13 on at

    Here label i meant to say "RequestDate" and it's possible to pick with class name?

    Like class (25 parm fields)

    I want to get 25 attributes name in the runnable class so that what to be done? Give example.

  • Martin Dráb Profile Picture
    238,743 Most Valuable Professional on at

    That's the name of the member, not a label.
    Personally, I would use the new metadata API. AxClass has a Methods property with a collection of methods and each AxMethod has an Attributes property.

  • Lakshmi Profile Picture
    13 on at

    /using Microsoft.Dynamics.AX.Metadata.MetaModel;  // i declared golbally
    
            AxClass classs = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetClass(classStr(LeaveReqeustContract));
    
            classs.Attributes // how to loop list of parm attaribute name

    I have  tried the code following, shall you give me guidelines or code to get the list of parm method attributes in loop.

  • Martin Dráb Profile Picture
    238,743 Most Valuable Professional on at

    classs.Attributes contains attributes of the class, which isn't what you need. I already told you the name of the right property: Methods.

    Regarding the loop, have you tried using an enumerator, as demonstrated in the blog post?

  • Lakshmi Profile Picture
    13 on at

    Hi Martin sir,

    Sorry for the late reply, I'm not aware of metadata API please give me your example for that. With axClass and AxMethod.

    Thanks 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 583 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 378

#3
Diego Mancassola Profile Picture

Diego Mancassola 255

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans