Roam
Roam copied to clipboard
Subform for 1:M data collection
Is it possible to integrate an subform related to an another table.
Here my explanation: My geometry hold a pk.
An related table is linked by pk/fk to collect 1:M data for this geometry? Is is possible ?
I don't know of a way to do this directly, but I've done it via workaround with Spatialite triggers. For example, I have a table with polygon geometry called Workplan and a table with point geometry called WorkplanProgress. I use a trigger to populate the pk/fk relationship each time I collect a WorkplanProgress point. In post-processing, I drop the geometry column from the WorkplanProgress table, since it's not needed. From my testing, I wasn't able to collect data in Roam without having a geometry column, so I don't think you can skip it.
Here's the code snippet
CREATE TRIGGER workplan_prog_inherit_id after insert on WorkplanProgress BEGIN UPDATE WorkplanProgress set workplan_uid = (SELECT Workplan.workplan_uid FROM Workplan, WorkplanProgress WHERE ST_Intersects ( WorkplanProgress.geom, Workplan.geom) AND WorkplanProgress.ROWID = NEW.ROWID) Where WorkplanProgress.ROWID = NEW.ROWID; END;
Thanks, Fine for the pf/fk generation and post-processing by dropping geometry field. Now, how about maintaining attributes related? For example, from my main form, from one measurement(point), I want to capture unlimited number of photos or delete one of them?
The idea is to access related data from the main form?