I've been trying to use the reference relation widget win QGIS 3.20 with a filter expression and running into quite a bit of issues. If the expression filter is "self contained" (meaning, it only uses values / attributes / fields from the referenced layer) then everything works as expected.
But im trying to use the expression filter to only list items that are in the vicinity (buffer) or intersect with the feature being created.
And it seems its impossible to use the "parent" geometry in the expression in any way that works.
For example, if I use the following expression
it properly shows in the drop down list only those points where the coordinates are even. This is not what I need, but was a way to verify I could access the referenced feature's geometry.
How do I compare the referenced feature's geometry to the point / feature I am creating?
intersects($geometry,geometry( @current_parent_feature ))
intersects($geometry , @current_parent_geometry )
(and quite a few other options as well). Variables like
$x don't work as they refer to the item being filtered and not the feature being edited / created.
I can use the following expression in the "default value" field and that works fine (selecting the item that intersects the current feature) but I would like to filter the dropdown as well (so that I can list, for example, all features within a 10m buffer of the feature being created)
(where 'poste' is the referenced layer im trying to filter)
(I also tried with overlay_intersects in the expression filter until I realised that the "current" object in that expression filter refers to the iterator we're trying to filter).
Is there any way at all to filter this?
If I use the Value Relation mechanism I can use one of these filters and it works fine.
Looking at the code when the reference filter expression was added, I see that
are all "highlighted" in the expression builder so I'm guessing its meant to be a hint to use those variables/functions as a way to access the currently-being-edited feature. But I haven't had any luck so far. (code commit is here: https://github.com/qgis/QGIS/commit/a853f2643df7d35f0980e8f92acb688fe3f15344 )