qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.08k stars 2.93k forks source link

Cascading forms are not working with new "current_parent_value"-expression over fom-levels (parent/child/subchild) backwards in value-relations #57957

Open koenigherford opened 1 week ago

koenigherford commented 1 week ago

What is the bug or the crash?

Great to have the new "current_parent_value"-expression in QGIS 3.38.0 developed by @nirvn! The new function is a great enhancement using parent- and child-forms. It works well in the standard-direction creating a parent-feature-> creating one ore more child-features->creating one ore more subchild-features. All child-forms are using the correct filter-values from the (unsaved) parent-feature when adding new-childs grafik

But when changing a value in the parent feature afterwards, the filters of depending cascading forms based on "current_parent_values" are not working (as expected): I expected do have a impact on the other child-filter-values depending on changes in the parent-form(s) - but the (now invalid) selections are not affected: grafik

The expected behavoiur was: grafik

Steps to reproduce the issue

set up a project with a parent / child /subchild /...-forms using "current_parent_value"-expression in filter-expressions of cascading forms (or use attached sample-project (polygon-layer is parent-layer))

See result

Sample-project: current_parent_value.zip

Versions

QGIS version | 3.38.0-Grenoble | QGIS code revision | 37aa6188bc -- | -- | -- | -- Qt version | 5.15.13 Python version | 3.12.4 GDAL/OGR version | 3.9.0 PROJ version | 9.4.0 EPSG Registry database version | v11.004 (2024-02-24) GEOS version | 3.12.2-CAPI-1.18.2 SQLite version | 3.45.1 PDAL version | 2.6.3 PostgreSQL client version | 16.2 SpatiaLite version | 5.1.0 QWT version | 6.2.0 QScintilla2 version | 2.14.1 OS version | Windows 10 Version 2009   |   |   |   Active Python plugins qfieldsync | v4.9.1 db_manager | 0.1.20 grassprovider | 2.12.99 MetaSearch | 0.3.6 processing | 2.12.99 QGIS version 3.38.0-Grenoble QGIS code revision [37aa6188bc](https://github.com/qgis/QGIS/commit/37aa6188bc) Qt version 5.15.13 Python version 3.12.4 GDAL/OGR version 3.9.0 PROJ version 9.4.0 EPSG Registry database version v11.004 (2024-02-24) GEOS version 3.12.2-CAPI-1.18.2 SQLite version 3.45.1 PDAL version 2.6.3 PostgreSQL client version 16.2 SpatiaLite version 5.1.0 QWT version 6.2.0 QScintilla2 version 2.14.1 OS version Windows 10 Version 2009 Active Python plugins qfieldsync v4.9.1 db_manager 0.1.20 grassprovider 2.12.99 MetaSearch 0.3.6 processing 2.12.99 ### Supported QGIS version - [X] I'm running a supported QGIS version according to [the roadmap](https://www.qgis.org/en/site/getinvolved/development/roadmap.html#release-schedule). ### New profile - [X] I tried with a new [QGIS profile](https://docs.qgis.org/latest/en/docs/user_manual/introduction/qgis_configuration.html#working-with-user-profiles) ### Additional context _No response_
koenigherford commented 1 week ago

I just saw in attribute-table, that the inherited value from the parent field is not stored (just NULL instead of ID...) in attribute-tabe when layer-properties/manage custom forms/myInheritingField -> "Apply default value on updated" is checked. When checkbox is unchecked the inherited value is stored as expected. (To force QGIS to be aware of changes in the parent-forms I thought the "Apply default value on updated"-checkbox shall be checked in child-forms) grafik grafik

Additionally the inherited default-value is completely lost when adding one or more childs in the same child -level when "Apply default value on updated" is checked grafik grafik

koenigherford commented 1 week ago

Aditional information: The approach to filter the value-relation table was to use
subtype_type_id_ref" = current_value('child_2_type_from_child_1') (in child2-level in sample-project above) instead of longer existing "subtype_type_id_ref" =coalesce(current_parent_value( 'child_1_type' ),3) (which was available only in this limited case in versions <3.38.0)
because there is/was still the issue that QGIS does not recognize the current_parent_value correctly every time when filtering value relation-tables. (Maybe related to https://github.com/qgis/QGIS/issues/55897). Maybe its worth to play around with the sample project V2 and add some childs and modify the parent values afterwards to see the exact confusing behaviour.

The additional sample project (using coalesce(current_parent_value( 'child_1_type' ),3)) is: current_parent_value_v2.zip

The nearly same project (using current_value('child_2_type_from_child_1') andchild_2_type_from_child_1 as default value with checked-"apply default value on update" with current_parent_value( 'child_1_type') was shared above.