In QGIS, I am trying to update a feature based on entries made on a nested form (relation).
Considering:
- Layer1 has Field1 that should capture the value of Field 2, and field in Layer2
- Layer2 is nested in the form of Layer1 via a Relation.
The problem I have is that when I'm creating a feature this way, the get_feature()
function won't get the value because it is not actually written in Layer2 until the editing is done, so the feature remains empty. If I then go back to the attribute table and update anything, the get_feature()
will work, but I want this to happen without having to manually update every entry I do.
I tried several ways to use current_value()
to get the value being edited in Layer2 but didn't find a way to make it work...
To test this, I'm using something as simple as this:
if(get_feature('Layer2', 'ID_OBS_Layer1', "ID_OBS_Layer2") is not NULL, 1, 2)
as a default value (with an update) for my field entry. This work for a feature where the editing is closed, but not while it is being edited.