How can i save the name of the attribute as the value of another attribute

Hi, I need to save the name of the attribute as a value in another attribute. Say, I have 2 attributes Attribute1 and Attribute2 in an entity A. I have another Entity B with the attribute as Name. I want to save “Attribute1” and “Attribute2” as a value in “Name” field. how can i achieve that? Thanks, Varun
2 answers

Hello Varun,

I suggest having a look at the MxModelReflection community module as it does exactly that for all entities in selected domain models – you’re probably better off using this rather than reinventing the wheel.

Hope this helps 


The usual approach to solve this kind of requirement is to use the MxModelReflection module from the App Store: the module creates objects based on your domain model, and you can retrieve these objects and use their names.

Alternatively, you can use the Mendix runtime API in a custom Java to get the name of an attribute, or to access an attribute. To get the value of an attribute whose name is stored in Attribute2, you could use:

IContext context = getContext();
IMendixObjectMember<?> memberToGet = inputObject.getMember(context, "Attribute2");
String value = inputObject.getValue(context, memberToGet.getName()).toString();
return value;

Do note that you probably should not try to create such a system in Mendix. Mendix may not be the best solution if you have requirements that need such constructs to solve. The complexity of such a solution should not be underestimated.