If you want to uniquely identify objects then use an autonumber field and set that value as the key to find the object.
Similar to Autonumber suggestion provided by Ronald, what we did is, we added an attribute “UUID” (aka Unique ID), which is a random string generated when the object is created. Can be achieved with the help of after create events.
This UUID can be used for references and identifying objects.
Having some sort of unique ID other than the DB id provided by mendix is always a best practice.
NOTE: There is also a way to get the Mendix ID of the object and we can assign the same ID to the UUID as well. But we need a different attribute to achieve what are you trying to do.