4

I have a point geometry layer that correspond to objects to street lamps. For each point I have the key field "CODE_ID".

enter image description here

On the other hand, I have a maintenance history table. This table stores the "CODE_ID" field, the "DATE" field and the "DESCRIPTION" field.

enter image description here

Both objects (geometry and table) have the key field "CODE_ID".

My goal is to configure the Attributes form of the geometry layer so that it shows in some way the maintenance history that has been done for each geometry object

My first approach to finding a solution is to create a Join between the geometry layer and the table:

enter image description here

Then I would like the Identify features tool form to somehow show that each point has 'n' related maintenance table records ordered by date.

For example, a solution for me would be to be able to see the joined field "STREET_MAINTENANCE_DATE" as a dropdown list, which when selecting a date shows me the corresponding content of the "DESCRIPTION" field.

How should I have the Attributes form configured for the "STREET_MAINTENANCE_DATE" and "STREET_MAINTENANCE_DESCRIPTION" fields so that they behave this way?

For now, for the "STREET_MAINTENANCE_DATE" field I have chosen the Widget Type Value Relation with the following information:

enter image description here

However, the result is not what was expected. The "STREET_MAINTENANCE_DATE" field appears as a disabled dropdown list.

enter image description here

I would like to ask you for your approach and your experience (best practices) to complete this kind of work. If it's possible, I would like to ask you for the maximum details of Attributes form configuration (options, expressions,...) necessary to achieve this.

1 Answer 1

4

You can create a relation between the geometry layer layer and the table having the extra data.

Go to project/properties/relations/add relation. Make sure to give a name to the relation.

enter image description here

Then open the geometry layer properties, custom form. Opt for the drag and drop designer. Add fields from the geometry layer, then drag and drop the relation you have just created.

enter image description here

Now when opening the geometry layer attribute table or the feature info, you will also see the related table information. You can switch between a list or a table

enter image description here

4
  • This proposal solves my objective. Answer accepted. But, if possible, I would like to know is it possible an alternative to achieve the same with the join support and the use of some expression on Attributes form, to show a dropdown list as I comment in my question Feb 20 at 17:30
  • @IngridIngravida The Join tool will only do one-to-one joins so not suitable for your use case. JGH's answer is the ideal approach. You can change the display expression in the list of child features (shown as a1, a1, a1 in the last image) to show the date instead, so you can instantly click on a date and see the corresponding info on the right hand panel. Either select dropdown at Expression in the child form, or set it up permanently in the child layer's Properties (Display > Display Name), also configure the Attributes Form to drag and drop designer, to only show the date and comments
    – she_weeds
    Feb 21 at 0:42
  • 1
    @IngridIngravida If you really want a dropdown list GUI then you need to carry over the data to your parent layer but may not be good practice. Create 2 additional fields in parent layer: (1) date field called DATE_SEL with Value Relation widget, Layer = STREET_MAINTENANCE, Key and Value = DATE. Filter expr = current_value('CODE_ID') = "CODE_ID" , (2) comment field with text edit widget (can disable editing); default expr (apply on update) = aggregate('STREET_MAINTENANCE','array_agg',"DESCRIPTION",attribute(@parent,'CODE_ID') = "CODE_ID" and attribute(@parent,'DATE_SEL') = "DATE")[0]
    – she_weeds
    Feb 21 at 1:41
  • 1
    You will get this result (GIF) but it saves the actual data in your parent layer which isn't really appropriate. Whereas if you change the display expression as mentioned earlier you get this result (GIF) in form mode
    – she_weeds
    Feb 21 at 1:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.