I've got a Java action in which I hold an IMendixIdentifier and I want to compare objects with this using XPath, retrieving objects which are associated with it, like this. IMendixIdentifier id = someJobFile.getObject().getId(); String target = [some function of id] List list = Core.retrieveXPathQueryEscaped(getContext(), "//PipsAndSubbies.JobTaskMapping [PipsAndSubbies.JobTaskMapping_Job/PipsAndSubbies.Job/PipsAndSubbies.Job_JobFile/PipsAndSubbies.JobFile/id = %s and [some other constraints]" , target); Question: how to I get the target string to pass into Core.retrieveXPathQueryEscaped and substitute for %s, given the IMendixIdentifier, to match an object's id field?
You can use id.getGuid(). This method returns a variable of type long.
You can also use someJobFile.getGUID(). This method returns a variable of type String and is direct suitable to use as target.
It is possible to optimize your query a little bit. Look at this query: