I have a point layer called "territories" with fields "species" and "red list status" (both text). The field "species" already contains values. "red list status" is NULL for all features.
Then I have a reference layer (excel file) called "reference" already imported into the project. The excel file also contains a field "species" and a value for "red list" (both text).
In QGIS, I created a project relation called "reference birds". The referenced layer is "reference", the referenced field is "species". The referencing layer is "territories" and the referencing field is "species".
Based on this project relation, I configured the attributes form of the layer "territories" in a way that, when I add a new feature with a value in field "species", the value for "red list status" is automatically filled in by QGIS. Works fine.
EDIT: The configuration for the field "red list status" in the layer "territories" is as following:
- widget type: 'value relation'
- Layer: "reference" (the excel file)
- Key column: "species"
- Value column: "red list status"
- Filter expression: "species" = current_value('species')
BUT: I want to automatically fill in the value for "red list status" for features that already exist in the layer "territories". Ideally, this should be done based on the relation I created.
I tried to find a way to do this via the default value for field "red list" but I don't know how to involve the relation in the code (for example with CASE WHEN ELSE function).
How can I auto-update the values for field "red list" in my point layer based on my reference table so that the value for "species" is the condition for filling in the value for "red list"?
