The best practice for this case is to use a new helper entity to have an entity A and B and a third one called helper which has associations A *-1 Helper and B *-1 Helper and constraint your xpath using the helper, however if this doesn't work you might need to loop and to find the object from list A based on it, the third and the most optimal way is to use the query that Tim sent you
The best way to accomplish this is by changing the association so that both entities refer to each other. Then you can retrieve via XPath using the association only.
I have tried, as you said, but that didn't work. I have attached the screenshots below:
I know its dumb to put list of objects in XPath, but what should I put here instead of that list?
The retrieve-activity does not support your requirement. Retrieving the objects B having an association to one of the objects A in the A-list. Mendix has no other activity doing this.
You can accomplish this by importing the OQL-module and execute this OQL:
from YourModule.B b
where b/YourModule.B_A/YourModule.A/IdAttribute in (from YourModule.A where <yourwherequeryforlistA> select A/IdAttribute)
select *