Hey Francois,
You need to use retrieveByPath, but you need to make sure your non-persistent objects are in cache.
https://apidocs.rnd.mendix.com/9/runtime/com/mendix/core/Core.html#retrieveByPath(com.mendix.systemwideinterfaces.core.IContext,com.mendix.systemwideinterfaces.core.IMendixObject,java.lang.String)
Similar question: https://community.mendix.com/link/space/microflows/questions/131035
Best regards, Slavko