roam-qgis / Roam

Simple data collection built using QGIS.
http://roam-docs.readthedocs.org/en/latest/
GNU General Public License v2.0
166 stars 60 forks source link

Capture value from field where capture layer not geographic #450

Closed TonyFMCMC closed 4 years ago

TonyFMCMC commented 4 years ago

What is the correct expression format to populate a field using the 'Capture value from field' option in Roam Config Manager where the capture layer is non-geographic.

E.g a field on my form is "Activity". I want to populate another field on the form "Details" with the value in a local geopackage layer "Activities" in a column "Description", where the column "ActivityID" equals the entry on the field on my form "Activity".

So I select Activities as the capture layer, select Description as the Value Field, but I think the problem is in the join expression. Naively I would expect that "ActivityID"="Activity" would work. But it doesn't, nor does the reverse. Nor attribute("Activities","ActivityID")="Activity", nor anything else I tried.

Help please. Roam 2.6.0, QGIS 2.18

TonyFMCMC commented 4 years ago

So, I think there is a timing issue here, and now that I think about it it is obvious. The expression is only evaluated when the polygon is created and the associated form loaded, or on save (depending on whether "Capture and save", "Capture only" or "Save only" is selected in Roam Config Manager.

So instead I created an event on the 'Activity' field, on update, setvalue, Details, only when True, New value concat( attribute( get_feature( 'Activities','ActivityID',@value),'Description'),' ',"Details").

And this worked! Notes for the curious in the new value expression:

A bit more documentation of this functionality would be helpful please.