Lock down the ability to enter a value in a field after the form has been submitted once.

628
4
Jump to solution
11-01-2018 12:45 PM
deleted-user-_W8EkYyUrB6K
New Contributor II

Hi folks!

Posting for the first time, but have been dependent on the info shared in this group since I have embarked on the Survey123 journey! Ismael Chivite‌ and James Tedrick‌ have been amazing at providing answers along with the community at large; definitely super grateful for that!

The issue that I need help with, is locking down the ability to enter a value in a field after the form has been submitted once. My form is used to collect information on damaged sites and allows users to enter a date in one of the fields for when an incident occurred.

For on going incidents, users can go back into the same form/record and update info as things progress. However, when the incident occurred will never change (i.e. if an incident occurred on 2018/11/01, regardless of how many times someone goes in to update information on that site, the date of the incident will always remain 2018/11/01 as that's when it happened). I would like to be able to essentially make the field value read-only after the first submission. 

Is there currently a way to do this? I have used the once() function for other things but don't believe it is meant for this (and I definitely cannot self-reference the field in the calculation for that field). Any help would be appreciated!

1 Solution

Accepted Solutions
JamesTedrick
Esri Esteemed Contributor

Hi Muqsit,

The once() function is designed to ensure a calculation is only done once, so is appropriate for questions with calculations.  Aside from that, you could use the new capability of readonly columns to use expressions to set a criteria for the question to be readonly - if there is a hidden status field, you could set certain questions to be read only when the status is closed.

View solution in original post

0 Kudos
4 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Muqsit,

The once() function is designed to ensure a calculation is only done once, so is appropriate for questions with calculations.  Aside from that, you could use the new capability of readonly columns to use expressions to set a criteria for the question to be readonly - if there is a hidden status field, you could set certain questions to be read only when the status is closed.

0 Kudos
deleted-user-_W8EkYyUrB6K
New Contributor II

Thanks James, appreciate the response! I was not aware of read-only columns supporting expressions. In light of that, is there a property that counts how many times a particular record has been submitted? i.e. if I submit a form for 'Site A' today and then it is re-submitted with updates to attributes 9 times after, is that count being captured? Can I create hidden field that could capture that? If so, I could use it in the read-only expression such that the Date of Incident field becomes read-only if this 'count' value is greater than 0.

0 Kudos
deleted-user-_W8EkYyUrB6K
New Contributor II

I attempted my previous idea by using wrapping the end_date in a once function in a hidden field and then using an expression to set the Date of Incident to read-only if there was a value in the field capturing the end_time once. However, the end_time would populate as soon as the survey was opened, making the Date of Incident read-only from the start. Not sure if there is a glitch as end-time should only be calculated when the user submits a survey (at least that is my understanding of it). 

0 Kudos
UriGilad_EsriAu
Esri Contributor

Great solution, @JamesTedrick 

Currently this only works on the app, and not on the web version.

I'll add that you can set a 'Lock' or 'Readonly' question for the user to click when they are done with the questions that need to be locked. You can make it 'select one' with only one option - Lock. This question can be 'required' so they must lock it before submission.

If you put the Lock question at the bottom of a group, and make the whole group readonly if question = Lock, it will lock the entire group and the lock question itself, which is great if you want the user to not be able to access again after confirming the lock. You can then put a note to show up after they lock: 'your questions are locked, please submit the survey'. Make sure they're aware that if they survey went 'readonly' it doesn't mean it was submitted.

If you want to enable the readonly for editing again you will have to set the Lock question to null in the feature layer.