Association List comparison with contains

0
Hello,  I'd like to improve my MF a bit and was wondering if the following Issue could be solved via XPath:   Given is a List of Elements (Areas) which are associated with multiple roles and some entities in between. Also, I have a list with Roles. Note: The Roles in question are not related to Mendix Roles. They are just another domain entity.   Now, I'd like to check if any of the Associated Roles does match with my list of Roles. Something like:   -Filter expression on AreaList -'Area/...some entities.../Roles' contains '$RoleList'   Given two Roles, this should retrieve or filter all Areas that has either both roles associated or any of the roles in the list.   Currently, using the = operator, I retrieve only the Areas that has both roles assigned. Retrieve from DB raises an "Unsupported type List" Error     Does anyone know a simple way to Achieve this? Kind Regards, Pascal
asked
1 answers
0

Maybe the most simple is to create a loop over the roles and retrieve the areas from the database with something like [area_entity/entity/role_entity = iterator_role]. Store those in a list and at the end of the loop you have all the areas. As you state that an area should be retrieved when both roles or one of the roles is associated then checking on if any of the roles match is enough.

When you need to go over may roles then this could become a performance issue, then maybe split the iteration over multiple parts. 

Another option could be to use the OQL features to create a statement where to comparison to the list of object(id) can be used as this is not directly possible in the xpath statement, hence the error you are getting. There is an idea on the forum for Mendix to support comparing lists in xpath but this has not been implemented, see https://community.mendix.com/link/space/xpath/ideas/580

answered