QGIS Shapefile Relations – How to Update Parent from Child and Vice Versa in QGIS Relations

qgisrelationshapefile

The functioning of my project under QGIS is based on the use of information between parent and child (relation layers).

I need to access specific information to control visibility of containers and filter lists.

In my example, I have 2 layers: [T]_DATA_PT (parent) and [T]_SURVEYS_Flora (child).

When I add the information "03-Flora" in the field "COMPART", I need to access this information in the field "COMP" of the child layer (see pictures).

Pic
Pic2

My first solution was to update the id with some information like "id" = uuid || '@' || "COMPART". The relation make it possible to access the field "COMPART" of the parent through the field "id".

Unfortunately, this brought to errors on Qfield with residual information between several entities (in the parent layer).

I tried to use a double relation (relation on "id" and "COMPART"), but it cannot work this way.
It also doesn't work with "value relation" widget, the value is only found when the parent's form is closed.

Do you know a better solution ?

I share a small project to illustrate my issue.
QGISProject

Best Answer

To resolve my issue, I finally changed the way my project was working.

First, every field which was in the parent layer and supposed to appear in the child layer, migrate directly in the child layer (no more in the parent layer). In this example: field "COMPART" is now located in the child layer. Then I joined child layer with parent layer to have the information in the parent layer, when the two layers are saved.

In this way, I avoided really problematic errors on Qfield and I stopped trying to pass information through the field "id" which also brought me to lose data sometimes.

Finally, except through the field "id", I never found another way to access information of the parent layer through the child layer, while the parent is still in edition mode.

Related Question