Deactivate option if selected once

I have been thinking along similar lines, as I am configuring forms with 10s to 100s of selections (inside a cascading filter), and the field user may forget that they've already completed "A1" and either do it again or omit it and have to go back later [1]. I don't want to remove choices entirely just in case they do need to resubmit, and updating a definition / filtering it from view would do this. Rather I prefer to add a traffic light signal to the displayed label to visually show that group/item is not started/in progress/complete,

eg Group A is not started, B is complete and C is in progress, C1 & C3 are incomplete and C2 is complete:

Select the Area: :record_button: :red_circle: Group A :record_button: :green_circle: Group B :radio_button: : :orange_circle: Group C
Seclect the Item: :record_button: :red_circle: C1 :record_button: :green_circle: C2 :record_button: :red_circle: C3

Up until now I have been using PowerQuery to grab the submissions and look at unique items status as well as a count of incomplete items within a set (0 = set is complete, >0 & <100% = set in progress, 100% = set not started) and use this result to build the displayed label as =":traffic_light:" & label_text_cellref for the choice list [2].

This doesn't help the offline field user though, so...
I am sure I have seen this workaround on the forum (@mathieubossaert was it you, this is close but no banana?), but I can't get the right search terms today to find the post to link/credit. I haven't tested the below yet, but this is the push I needed to give it a try. I have a working version now, tested in Enketo & Collect as a draft, unpublished form

collection_forum.xlsx (16.0 KB)
This version implements the below, it also adds a testing confirmation note at the end to show the current selected and all-time on device selected options. I added device ID as well, but it's not required.

If:

  • You only have one device collecting information or one device in an area, and
  • you don't update the form definition or delete/reconfigure it [3].

Then you can calculate a value that concatenates a last-saved string plus the currently selected value to create a string of all selected values, increasing with every submission. This can then be used to filter out or flag options from your list

eg -
Enumerator completes a submission with your block_code = b1, then another for b2 then b34;
In the form there is a readonly/invisible text entry or a calculate say name= blocks_completed with default / calculation as

if(${last-saved#blocks_complete}='',concat(${deviceid},':,',${last-saved#blocks_complete}, ${block_code},','),concat(${last-saved#blocks_complete}, ${block_code},','))

This will return device-id:, b1, after the first submission and device-id:, b1, b2, after the second, device-id:, b1, b2, b34, etc etc

If you update your choice_filter for block_code so it's now the below;

site=${site_code} and if(${show_complete}='OK', (contains(${last-saved#blocks_complete}, concat(',',name,','))), not(contains(${last-saved#blocks_complete}, concat(',',name,','))))

then on the fourth submission,b1, b2, b34 should all be filtered from view [4] unless the 'show completed' trigger question is selected, and then only those will show.

If you then wanted to make the completed ones accessible, a question before 'Show completed items?' could be used to change the choice filter behaviour from not(contains()) to contains().

The next step would be to combine the traffic light definition update with the on device filtering so you get an instant 'I have done these' indication and a delayed 'someone has done these' indication.


[1] They could also look at the saved forms instance IDs / keep a paper checklist and mark them off / work through in order A1, A2, A3 and at each new submission the 'last entry was ${id}' message would tell them the one they just completed so pick the next one. None of these are foolproof or ideally practical.

[2] Excel will allow emoji use, however they render in grayscale in desktop app, and correctly in web. Can be annoying to tell the difference between shades.

[3] Updating the definition will clear the last saved value on Collect but not on Enketo, even with a Ctrl-F5 hard refresh - where is this info cached? Opening a private window resulted in a fresh slate.

[4] You would need to make the names more unique as completing b11 would filter out b1 etc. Or modify contains() to search for , value, or whatever you delimit the concat with. In the example I am searching for the value bracketed by , rather than change b1 to b01 etc.

1 Like