I have a project in QGIS to register field points (x,y), where I collect different types of samples (soil, water, rock) for the same point. I need that in the "Amostras" table, when some items are provided, the form automatically fills the field (cd_numero_campo), using as a reference a field (nm_estacao) from the "Pontos_de_campo" table that has not YET been recorded, that is, it is in memory.
The keys to link the two tables are: "uniquerowid" and "parenterowid". The code I used to fill in the cd_numero_campo field was:
''' substr( attributes( get_feature('Pontos_de_Coleta','uniquerowid',"parentrowid") )['nm_estacao'], 1.7)
- '-' + "class_id" + '-' + substr( attributes( get_feature( 'Pontos_de_Coleta','uniquerowid',"parentrowid" ))['nm_estacao'], 9,12)
- '-' + coalesce( "nm_extra_ample" ,'') '''
However, it has not worked consistently. When I start work without any pre-existing points in the table, the "cd_numero_campo" field is null, from the second point placed, sometimes it works and sometimes it doesn't, but if I record the features and edit the fields, it fills in appropriately.
I understand that the problem is due to the fact that both tables have data in memory, not yet saved. Could anyone tell me what should be suitable for it to work well?
Below is the link to the data.