There is no function I know of that will return the object based on the ID directly. But, if you extract the id from the identifier object that you get as a string, the id can be used in an Core.retrieveXpathQuery like the simple version below:
List<IMendixObject> mxObjects = Core.retrieveXPathQuery(getContext(), "//<ModuleName>.<EntityName>[id="+<ID as string>+"]"); IMendixObject mxObj =mxObjects.get(0); return mxObj;
In this java action the input parameter is the ID as string from the identifier object and the return value is the entity that you are searching for. The result of the query will be a list of IMendixObjects, but as there will be only 1 object returned, I just take the first object from the list and then this will return the object based on the input id value. The example is meant just as an example to demonstrate the function, a check for empty list could be useful and the retrieve could use a limit etc. But you can use this a a reference for the implementation of the real function.
There is a direct function which returns a list of mendixObject or a single object
List<IMendixObject> objectlist = Core.retrieveIdList(getContext(), ids); IMendixObject myobject = Core.retrieveId(getContext(), id);
Both solutions suggested by Erwin and Chris are good solution to do this. One addition for your specific case, from your question you are saying you are trying to retrieve the original value, it is probably better to create your own Java action to eliminate the string mutation activities. That way if the platform notation ever changes your action will keep working.
The code below is capable of returning the Original value, exactly the same way as the function for community commons. However you must make sure that the input memberName is the name of an association. The action will then return null if it was empty or the actual object that was associated.
// BEGIN USER CODE IMendixIdentifier myId = (IMendixIdentifier) this.MyInputObject.getMember(this.getContext(), this.memberName).getOriginalValue(this.getContext()); if( myId == null ) return null; else return Core.retrieveId(this.getContext(), myId); // END USER CODE