Exclude entities currently referenced on a node with entity browser I have content type that references a custom entity and uses an entity browser widget to select them.
I want to create a view for the entity browser that excludes entities that have already been selected on the current node so that they're not selected twice.
Not sure if this can be done with default functionality or it needs a custom module
You are listing entities as your base type, but you want to filter based on the current node.
You need to introduce the information about the nodes that already reference (all) entities, and also what the current node is.
You do that by using the &quot;backwards&quot; Relationship, the one that goes from Entities back to the nodes that reference them. This Relatinship will be named something like Content using field_entity_reference and its Description will be Relate each Content with a field_entity_reference set to the content.
It will not be named &quot;Content referenced from field_entity_reference&quot;, that one is the &quot;forward&quot; Relationship.
You can Require this Relationship because you want the results that do have a reference from a node.
Then add the Contextual filter Content: ID, make it use the Relationship, and configure
When the filter value is NOT available
Provide default value
Content ID from URL
When the filter value IS available or a default is provided
Specify validation criteria
Content
Your CT
Configure the other options as needed, but in the end:
More
Exclude
So we found all nodes that reference entities in our results, and used the Contextual filter to exclude the results related to the current node.