[QGIS-Developer] Question on current_value() expression in the context of filtering relation reference combo boxes

Alessandro Pasotti apasotti at gmail.com
Tue Dec 6 07:29:51 PST 2022


On Tue, Dec 6, 2022 at 3:59 PM Andreas Neumann via QGIS-Developer
<qgis-developer at lists.osgeo.org> wrote:
>
> Hi,
>
> In one of my form setups,  I would like to filter one relation reference widget combo box with a filter expression based on the selected entry of another relation reference value.
>
> A static filter like:
>
> szenario_art = 'Brand'
>
> works as expected and it returns the filtered values - but as soon as I try to base it on the value of another relation reference widget, it fails ...
>
> I tried
>
> szenario_art = current_value('szenario_art')
>
> but no records get selected.
>
>
> Questions:
>
> Does the current_value() return the "internal value" or the "human readable" value?

The internal value.

> Do I have to eval() something in the filter expression?

No.

> Is there a way to test "current_value" somehow? I tried to write the changed value into another text widget (with default values on update), but it will always return "NULL". In the expression editor, I also always get "NULL" in the preview.

That should work, the current_value returns the current value of the
feature being edited in the context of the form, this includes any
change that took place in the form.

You might get null values in the editor and the preview because there
is no form context in that case.




-- 
Alessandro Pasotti
QCooperative:  www.qcooperative.net
ItOpen:   www.itopen.it


More information about the QGIS-Developer mailing list