Idea
The retrieve operation from database XPath constraint should have the ability to retrieve by the object’s GUID.
Example:
Problem
There are a few times where we need to use the Mendix generated GUID to uniquely retrieve the object.
Workaround
Currently, we create an additional attribute on the entity named ObjectId and use an After Create microflow + Java action to retrieve the GUID and set it on the object. Then we can use a retrieve by DB on the ObjectId attribute. It would be nice if we did not need to make a new attribute and could just retrieve by the GUID.
Thanks Stefan, I was looking for this. I did however had to remove the getType() method from the ObjectType as in my case the ObjectType is just a String.
We use the following java action in the cases we need this.
// BEGIN USER CODE
List<IMendixObject> mxObjects = Core.retrieveXPathQuery(getContext(), "//" + ObjectType.getType() + "[id=" + ObjectId + "]");
if(mxObjects == null || mxObjects.isEmpty())
{
return null;
}
else {
IMendixObject mxObj =mxObjects.get(0);
return mxObj;
}
// END USER CODE