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

Hide an attribute in a form when a selection is made in another attribute, based on a field in the second attribute table #488

Closed TonyFMCMC closed 1 year ago

TonyFMCMC commented 1 year ago

The documentation on this isn't very clear so I'm posting my solution for others reference.

I want to hide an attribute (Tip Trips) in my form if the client of a team I select is 'MORELCC'.

I want to hide it because this data is irrelevant for this client, and there is a changing number of projects for this client, which I don't want to update the event every time there is a new project for this client.

So I create an event: For: select Team (List) On: Update Hide

Tip Trips (number)

Only when: attribute( get_feature( 'TodaysAllocations','ID',@value),'ClientID')='MORELCC'

'TodaysAllocations' is the table used in the 'Select Team' list dropdown, ID is the field in the table to compare with @value (which is the selected value of the attribute identified in the For: part of the event). 'ClientID' is the field in the TodaysAllocations table that contains the ClientID for comparison to 'MORELCC'.

Note that when the result of the 'Only when' is false, the event enables the Tip Trips attribute, even if it is marked as hidden in the design tab in Config Manager.

Roam version 3.0.6