Retrieve type of attribute

2
Is there a way to retrieve the type of an object-attribute? I've tried the Community Commons method getTypeAsString. As an input I use an attribute of an object, but then I get the following error: "The microflow expression is of type DateTime but should be of type Any object." Thanks!
asked
3 answers
2

You can write a simple java action for this:

return Core.getMetaObject("objectname here").getMetaPrimitive("membername here").getType().toString();
answered
1

You could use MxModelReflection to lookup the MxObjectMember and get the AttributeType.

answered
1

For the interested people: This is the code to iterate over the attributes, where oMyobject is the object that I passed to my java-action.

// BEGIN USER CODE

IMendixObject mo = oMyobject.getMendixObject();

IMetaObject metaObject = mo.getMetaObject();

for (IMetaPrimitive metaPrimitive : metaObject.getMetaPrimitives()) {

    Core.getLogger("TEST").critical(metaPrimitive.getName() + " " + metaPrimitive.getType().toString());

}

return true;
// END USER CODE

As you can see, I log them as critical to the Mendix-console :-)

answered