HowTo: Retrieve an Object where id in [1,3,65,86]

I have a couple of id's, usually no more than 4 and need to retrieve the objects having one of those id's. That seems not to be possible with the normal retrieve. I worked around it by looping over the array, doing multiple retrieves, each time adding the result to a ResultList. I can also do it by using an OQL statement. But is there realy no way to do this using the regular Retrieve activity, or have I missed some option?
3 answers

Why not use four variables and then use an XPath with the OR function? You might run into trouble if the four variables become three of five but you might even use an if function if you check first how many variables you have. So something like [ID = $var1 or ID = $var2 or ID = $var3 or ID = $var4].




You can use in Java the createXPathQuery. In your microflow build up the XPath string based on the infinite number of integers. Then pass this string to the Java action that returns a list of those objects. This way it does not matter how many ID's there are and you can just add another OR part to the string.


I would also go with Ronald's solution. Only problem could be that the amount of Id's is not always 4 (is that correct?).

A (dirty) solution could be to hard code a maximum number of Id's. If you have less than your maximum, you can fill the remaining variables with the first id. Your 'or' xpath does nit care about duplicates and only returns the result once.


I don’t think this is possible by the retrieve action.

OQL will be effective but sensitive for changes in the domain model.

Another workaround is to create an export and import mapping where you define the attribute as key attribute to retrieve the desired set of objects.