0

I have two PostGIS layers in QGIS 3.28, they are in a 1-N relation (association):

  • layer A (parent) without geometry (table)
  • layer B (child) with point geometry

layers_image

relation_image

Both A and B layers have the codsede attribute:

  • layer B (point, child): codsede is automatically filled by PostGIS with a function trigger;
  • layer A (table, parent): codsede is already filled with correct values.

codsede is not an unique value: the same value can be repeated in different rows/points and it corresponds to a specific place; different codsede values mean different places; the same value means that the "elements" are in the same place.

My intent is: when I add an element in the point layer B, I want to be able to "associate" a specific row from the parent layer A with the same codsede value. So the relation must be 1-1.

(Join function does not work for me, because points must be added and then they must be associated to an existing row in the layerA; or I must be able to add a new row in the layer A if missing)

I achieved half the goal with the relation reference widget in the point layer B (child): I can select a "row" from the parent A or, if not existing, add a new one.

module_image

However I need a filter that only shows rows of the parent layer A with the same codsede value of the element in the point layer B that I'm editing.

I'm trying to use ad expression like this to filter the values of the parent layer A in the relation reference widget:

 "codsede" = attributes( get_feature('layer_b','codsede', 'B_VALUE')) ['codsede']

where B_VALUE should be the value stored in the codsede attribute of the element that I'm adding/editing in the point layer B.

I do not know how to read the values from the feature I'm editing in the child layer B.

Can you help me?

properties_image

I cannot add a filter menu because it does not work with QField.

filter_image

0

Browse other questions tagged or ask your own question.