Conditional Visibility with many to many associated entities

Hello Community, I have two entities. Contractor and order. One contractor can be assigned to multiple orders and one order needs multiple contractors. That's why these are many-many associated. Now I want to build a page for the contractor. On this page all orders should be shown as Card and with click on the card an association to the contractor should be created (Card becomes green), another click should delete the association (Card becomes grey). I wanted to control the background-color of the card with conditional visibilty-expression. How can I check with conditional visibilty if there is an association between the contractor (object in data view) and the order (list in nested template grid), something like [not(contractor/contractor_order)] ???        
2 answers

it’s not out-of-the-box possible to create a condition with expressions as it is a 8-8 relationship.


You could fix this by using an entity in between.

Page would look like this


the nested dataview shows a selected object when present. This is defined by a datasource microflow, which looks like this:

The onclick of the container will trigger this microflow, which creates or deletes the selected object.

When Selected object is not existing, it creates one and set the associations between Selected and Order and Contractor = Selected

When Selected object is existing, it deletes the selected object = not selected

At the end I refresh the order object to push this to the frontend.

Instead of conditional visibility to show different containers with different styling, I use dynamic classes to change the color of the container background:


$currentObject != empty




my way: