MXObject getAttribute/getReference doesnt correlate to attributes passed in from widget

5
I have a widget where the user specifies an entity and attributes for that entity. I then want to iterate over the attributes so that I can call mxObj.getAttribute(attribute). The problem is that when an attribute is a path, it is stored as a full path in attributes, but on the mxObj(mxObj.getAttributes()) it is stored only as the reference itself (which is the one I should use when calling isReference/getReference/getAttribute). So what would be the ideal way to iterate over attributes of a mxobject if the attributes can be paths, taking into consideration that the attributes returned from mxobject.getAttributes() contains attributes such as 'changedDate'/'createdData'. Should I cross reference my attributes and mxobject.getAttributes() to see which ones are applicable ? Feels like this will give way for further erroneous behaviour. Edit: for clarity here is an example of what I am speaking of-> In my xml I have an entity (myentity) and a list of objects, each objects has an attribute (myattributes). When calling getAttributes() on the metaObject or a mxObject I get the following for an attribute that is a reference: 'MyFirstModule.AppProductConfig_Applicant' When inspecting my this.myattributes(or this.params.myattributes) I get this for an attribute that is a reference: 'MyFirstModule.AppProductConfig_Applicant/MyFirstModule.Applicant/FirstName' Now when I iterate over my_attributes to get all the values of the attributes I am using the full path of my reference, where only the association (as property key) is required/used in the meta/mxObject. So it is relatively easy to do(pseudo): if (/\//.test(my_attributes)) my_assoc = my_attributes.split('/')[0]; to get the actual attribute/assoc(the property key) from the entity, was just wondering if there was a more straight forward way ? I mentioned that I expect further erroneous behaviour due to references that can have long paths (given that you have one reference that is a long path another that is short), but I am still to investigate this.
asked
1 answers
0

You can use

var entity = mx.metadata.getMetaEntity({ className: this.myEntity});
var attributes = entity.getAttributes();

to get the attributes from any entity. MxMetaObject has methods like

.getAttributesWithoutReferences()

See apidocs.mendix.com and MxMetaObject

answered