HowTo: Retrieve an Object where id = $Id(type of Integer/Long)

  Retrieve an Object  from database by  id 。 XPath : [id = $Id] Error:Incompatible expression types: RatingEngine.Account, Integer/Long.          
3 answers

There is a difference between a database-id of an object and an object’s id that is used in the real world. Mendix shields away the object’s ids because it is (mainly) for internal use and prevents the common mistake of using the id as a public id of an object. That being said, you probably have a valid usecase, so here is what you can do:

First in your microflow add a Java-action ‘getGUID’, like I do  here for my Email-object:

then you can use the ReturnValueName to compare it to the object’s id.


Hi tangd,

There is a function which returns a list of mendixObject or a single object 

you can use this in java action

List<IMendixObject> objectlist = Core.retrieveIdList(getContext(), ids);
IMendixObject myobject = Core.retrieveId(getContext(), id)

you may want to create your own id for that (auto number is probably the easiest solution)