Announcements
No record found.
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.
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.
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; }
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.
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.
DataMemberAttribute doesn't contain any information about labels. Labels are taken either from the EDT returned by the method, or from SysOperationLabelAttribute.
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.
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.
/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.
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?
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.
Congratulations to our 2026 Super Stars!
Thanks to all of our 2025 Community Spotlight stars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
André Arnaud de Cal... 583 Super User 2026 Season 1
Giorgio Bonacorsi 378
Diego Mancassola 255