Deactivate option if selected once

1. What is the issue? Please be detailed.
I want to deactivate the option after the form is submitted to avoid repetition. Is it possible?

2. What steps can we take to reproduce this issue?

3. What have you tried to fix the issue?

4. Upload any test forms or screenshots below.
i am uploading my form. I want to remove/deactivate the combination of options from the form if they are selected ever in the past and the form is submitted
collection_forum.xlsx (19.0 KB)

Hi @yogita_karpate,

Unfortunately, it is not possible with how your form is designed.

An alternative is to fetch data from a CSV file and then update the external file frequently to reflect the changes.
See this https://docs.getodk.org/form-question-types/#select-from-external-dataset.

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

I know I've mentioned it with a "make sure you understand the limitations" disclaimer but I'm not finding it immediately either! I am convinced you understand the limitations. Thanks for spelling them out. Performance will also eventually be an issue with many hundreds of entities. You may also want to change settings to limit access to edits and multiple saves.

I don't think there's a strong reason for this and I'm becoming more and more convinced that it's confusing and dangerous.

It's stored in IndexedDB. This is persisted to a browser folder in clear text. It's impractical to access but if the data is sensitive you'll want to make sure the device is secured (which is recommended anyway). True that this is linked to formid, not formid/version so even more reason to change Collect's behavior.

As you've likely noticed, this is what we're working on automating with the Entity concept. You'll specify which entity property to save a form field to. Eventually that will update your local entities as well as the Dataset in Central. You'll be able to continue using choice filters exactly as you have or set an archive condition so that entities that have reached the end of a workflow are no longer transferred to devices.

I've made a separate post that contains an example of hiding options once selected and submitted, and also updates the definition using power query to add status emojis