I have 2 tables/layers:
- A Point table called "Chambers Used" with names in a field called "Chamber Identifier"
- A LineString table called "Ducts Used" including fields "A End" and "B End"
I'd like the form for when creating new items in the "Ducts Used" table to default the "A End" and "B End" attributes to the "Chamber Identifier" of the nearest (or touching) entry in the "Chambers Used" layer.
Things I have attempted in the Default value expression:
array_to_string(overlay_nearest('Chambers Used', "Chamber Identifier", max_distance:=5))
This just returns blank.
And this one inspired by Find item from start point and end point of line
array_first(
array_remove_all(
array_foreach (
overlay_nearest ('Chambers Used',$id, limit:=2),
if (
within (
geometry (get_feature_by_id ('Chambers Used',@element)),
buffer (end_point($geometry), 5)
),
attribute (get_feature_by_id ('Chambers Used',@element), 'Chamber Identifier'),
''
)),
''
))
This returns null.