Skip to content

Value Relation with current_value() not updating when changes made outside of the attribute form #63448

Description

@Skipper-is

What is the bug or the crash?

In previous versions (3.38 was last tested version where it worked) of QGIS, a value relation using current_value would select the first option if only 1 option was present in the drop down using this formula:

Image (Example table data would be Habitat codes A1,B2,C3,D4 corresponding to Habitat A, Habitat B etc so Habitat A would select A1)

Have 'partially' fixed through the use of the following default value formula:

attribute(get_feature('PrimaryCodes','Habitat', current_value('Habitat')),'Code')

Which fetches the appropriate one, but this only works when using the form.

Image Here is the functioning habitat codes for newly created polygons - created by drawing a polygon, selecting the habitat from the attribute form and pressing ok. If attributes are edited in the attribute table (or the feature is edited outside of the attribute form, such as moving a vertex, cutting, offsetting etc) the attribute reverts to NULL. Image After cutting the polygon through the middle using the Split Features tool Image Policies set to duplicate value, or use default both have a similar result.

Steps to reproduce the issue

  1. Using the attribute form value relation to select a value from a lookup table (which returns 1 result) Draw polygon using add polygon tool.
  2. Select parent value in attribute form, child field updates accordingly
  3. Press ok
  4. Verify in attribute table that it is correct:
Image
  1. Do something like cutting the feature using split features tool
  2. The original one retains its value relation value, but the new one is assigned null.
Image
  1. Also - if updating an attribute through the attribute table/not form, the value relation also reverts to NULL
Image However - if the row is selected, the value relation is re-assigned to the correct value.

If the form in the attribute table is used, the correct value is also assigned:

Image

Versions

QGIS version3.40.11-Bratislava
QGIS code revisiondf059ed19c
 
Libraries
Qt version5.15.13
Python version3.12.11
GDAL version3.11.3 (Compiled)
3.11.4 (Running) — Eganville
PROJ version9.6.2 (Compiled)
9.7.0 (Running)
EPSG Registry database versionv12.022 (2025-08-30)
GEOS version3.13.1-CAPI-1.19.2
SQLite version3.50.4
PDAL version2.9.0
PostgreSQL client versionunknown
SpatiaLite version5.1.0
QWT version6.3.0
QScintilla2 version2.14.1
OS versionWindows 10 Version 2009
 
Active Python plugins
AnotherDXF2Shape1.3.2
Auto_save1.0
changeDataSource3.1
FreehandRasterGeoreferencer0.8.3
html_table_exporter0.2.0
magic_map_loader1.2
qfieldsyncv4.17.3
quick_map_services0.21.4
splitmultipart1.0.0
StreetView3.3
TomBio3.4.4
what3words4.4
db_manager0.1.20
grassprovider2.12.99
MetaSearch0.3.6
processing2.12.99

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

ExampleGeopackage.zip
This geopackage is the one that has been used in this example, however other geopackages running a similar setup produce similar results - not limited to polygons, but lines, points etc all produce the same result.

:edit: This formula has been successful:
attribute( get_feature( 'PrimaryCodes', 'Habitat', coalesce("Habitat", attribute(@parent, 'Habitat')) ), 'Code')
But is there not a workaround for selecting the first value by default?

Metadata

Metadata

Assignees

Labels

BugEither a bug report, or a bug fix. Let's hope for the latter!RegressionSomething which used to work, but doesn't anymoreWidgets

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions