How can I create a Custom Conditions for admin panel that slot one to many relation fields

Dear all,

I am having a difficult in setting up a custom condition handler for different admin roles,

We have a collection type which has a one to many relationship to a collection type called company,

We will like to create a custom condition handle to slot the data base on the company name in this one to many relationship

E.g only return data with speific company name for some custom admin roles

The example on strapi website is too simple
the one to many relationship is an array structure with object of company table
Could anyone help us about this? Thanks in advance


Same issue with me.

I opened the topic at How to query collections from custom plugin in strapi?

You can follow it to find solutions.

Had the same issue, finding it’s unclear how to query relationship entity in the condition handler. hope someone can help.

One up for this topic!
I’ve found a dozen of questions how to handle custom conditions (e.g. here, here and here).
In the case of a one-to-one-Relation it works just finde but one-to-many-results in a filtered list without content. The filtering works but the content in the collection is missing and therefore not usable for a future content editor.

Hope someone can help here!

My workaround for now:
I created some boolean fields for the belonging content type and disable them for the role I want to restrict. Then I have lifecycle methods (beforeCreate and beforeUpdate) which check if the belonging value is found in the one-to-many-relation field. My custom condition now aims to the boolean and everything just works fine.
This is just a workaround as long as the one-to-many-relation doesn’t include too many possible values (in my case 3).