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:

(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.

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.

After cutting the polygon through the middle using the Split Features tool

Policies set to duplicate value, or use default both have a similar result.
Steps to reproduce the issue
- Using the attribute form value relation to select a value from a lookup table (which returns 1 result) Draw polygon using add polygon tool.
- Select parent value in attribute form, child field updates accordingly
- Press ok
- Verify in attribute table that it is correct:
- Do something like cutting the feature using split features tool
- The original one retains its value relation value, but the new one is assigned null.
- Also - if updating an attribute through the attribute table/not form, the value relation also reverts to NULL

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:
Versions
| QGIS version | 3.40.11-Bratislava |
| QGIS code revision | df059ed19c |
| |
| Libraries |
| Qt version | 5.15.13 |
| Python version | 3.12.11 |
| GDAL version | 3.11.3 (Compiled) 3.11.4 (Running) — Eganville |
| PROJ version | 9.6.2 (Compiled) 9.7.0 (Running) |
| EPSG Registry database version | v12.022 (2025-08-30) |
| GEOS version | 3.13.1-CAPI-1.19.2 |
| SQLite version | 3.50.4 |
| PDAL version | 2.9.0 |
| PostgreSQL client version | unknown |
| SpatiaLite version | 5.1.0 |
| QWT version | 6.3.0 |
| QScintilla2 version | 2.14.1 |
| OS version | Windows 10 Version 2009 |
| |
| Active Python plugins |
| AnotherDXF2Shape | 1.3.2 |
| Auto_save | 1.0 |
| changeDataSource | 3.1 |
| FreehandRasterGeoreferencer | 0.8.3 |
| html_table_exporter | 0.2.0 |
| magic_map_loader | 1.2 |
| qfieldsync | v4.17.3 |
| quick_map_services | 0.21.4 |
| splitmultipart | 1.0.0 |
| StreetView | 3.3 |
| TomBio | 3.4.4 |
| what3words | 4.4 |
| db_manager | 0.1.20 |
| grassprovider | 2.12.99 |
| MetaSearch | 0.3.6 |
| processing | 2.12.99 |
Supported QGIS version
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?
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:
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.
Steps to reproduce the issue
If the form in the attribute table is used, the correct value is also assigned:
Versions
3.11.4 (Running) — Eganville
9.7.0 (Running)
Supported QGIS version
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?