Skip to main content
added 49 characters in body
Source Link
Raúl Casado
  • 1.1k
  • 7
  • 19

I have a layer with a relate table (1-M) with three columns (fk_id, date, comment).

fidfk_id date comment
1 01 2021-02-03 Comment 1
2 02 2021-02-05 Comment 2
302 2021-03-02 Comment 3
4 02 2021-03-25 Comment 4
5 03 2021-01-11 Comment 5

I have also created a custom form for the layer and table.

Custom form

What I need is when I add a new record to the related table, the default comment must be the same as the last date for that fk_id.

So, in this example, if I create a new record in the related table using the form, the comment should be Comment 4.

I'm looking around the expression builder but I have no idea how to do this selection.

Anyone could give me a tip of how can I set this default?

I have a layer with a relate table (1-M) with three columns (fk_id, date, comment).

fk_id date comment
01 2021-02-03 Comment 1
02 2021-02-05 Comment 2
02 2021-03-02 Comment 3
02 2021-03-25 Comment 4
03 2021-01-11 Comment 5

I have also created a custom form for the layer and table.

Custom form

What I need is when I add a new record to the related table, the default comment must be the same as the last date for that fk_id.

So, in this example, if I create a new record in the related table using the form, the comment should be Comment 4.

I'm looking around the expression builder but I have no idea how to do this selection.

Anyone could give me a tip of how can I set this default?

I have a layer with a relate table (1-M) with three columns (fk_id, date, comment).

fidfk_id date comment
1 01 2021-02-03 Comment 1
2 02 2021-02-05 Comment 2
302 2021-03-02 Comment 3
4 02 2021-03-25 Comment 4
5 03 2021-01-11 Comment 5

I have also created a custom form for the layer and table.

Custom form

What I need is when I add a new record to the related table, the default comment must be the same as the last date for that fk_id.

So, in this example, if I create a new record in the related table using the form, the comment should be Comment 4.

I'm looking around the expression builder but I have no idea how to do this selection.

Anyone could give me a tip of how can I set this default?

Became Hot Network Question
Tweeted twitter.com/StackGIS/status/1408032192639418375
Source Link
Raúl Casado
  • 1.1k
  • 7
  • 19

Set default value based on multiple fields in QGIS

I have a layer with a relate table (1-M) with three columns (fk_id, date, comment).

fk_id date comment
01 2021-02-03 Comment 1
02 2021-02-05 Comment 2
02 2021-03-02 Comment 3
02 2021-03-25 Comment 4
03 2021-01-11 Comment 5

I have also created a custom form for the layer and table.

Custom form

What I need is when I add a new record to the related table, the default comment must be the same as the last date for that fk_id.

So, in this example, if I create a new record in the related table using the form, the comment should be Comment 4.

I'm looking around the expression builder but I have no idea how to do this selection.

Anyone could give me a tip of how can I set this default?