Model reflection question

0
At Daywize we allways strive to make the application adjustable by the customer. I am working now with dates where I want to able the user to select from the different date fields of an entity. With the Model reflection it is very easy to show all the datefields of a particular entity. Lets say I know the entity (MxObjectType) and I have the MxObjectMember name and thus now which datefield to use. How do I get from the MxObjectMember to the right field of the entity in a microflow? Or can this not be done? Regards, Ronald
asked
1 answers
0

If I understand you correctly and you want to retrieve the value of the the attribute you selected (MxObjectMember), you could pass your current object and the MxObjectMember to a java action with :

  • A any object input parameter
  • A MxObjectMember input parameter.

You do have to specify which datatype you would like to return from the java action. In the example I used string. You need to add some type checking if you want to return other datatypes.

public class Java_action extends UserAction<String>
{
private IMendixObject myObject;
private IMendixObject __targetMxObjectMember;
private mxmodelreflection.proxies.MxObjectMember targetMxObjectMember;

public Java_action(IMendixObject myObject, IMendixObject targetMxObjectMember)
{
    super();
    this.myObject = myObject;
    this.__targetMxObjectMember = targetMxObjectMember;
}

@Override
public String executeAction() throws Exception
{
    this.targetMxObjectMember = __targetMxObjectMember == null ? null : mxmodelreflection.proxies.MxObjectMember.initialize(getContext(), __targetMxObjectMember);

    // BEGIN USER CODE
    return this.myObject.getValue(getContext(), targetMxObjectMember.getAttributeName()).toString();
    // END USER CODE
}
answered