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.