Toggle read only state, but always default to read only

453
3
Jump to solution
05-03-2021 05:48 PM
Strahanjen
Occasional Contributor

Is there a way to toggle the read only state of a group of fields, that is not tied to a data value/survey question for an existing feature layer? 

We have a multi-page survey containing site information that is prepopulated from the feature layer. Biologists will visit the site multiple times throughout the season and thus, edit different elements of survey on subsequent trips. They usually only need a read only view of the site info, as they set out to do their field data collection (eg. fish, inverts surveys).  Occasionally, they will want to edit a small section of the site information data (eg, parking details, land access permission status). I don't want to make the entire site information page editable, because I'm nervous about inadvertent updates. To solve this, I added select_one questions at the top of each section, such as "Do you wish to edit land owner information?" Yes, No are the options. The related fields are read only at first, and then become editable if the user clicks 'Yes'. I achieved this by adding expressions like this to the readonly column (regex(${update_landowner_info},'No')

This works great until the user submits the form. At that point, the update toggle fields in the survey site information feature layer become 'Yes' . Then, the next time the user opens the survey, 'Yes' is the default for the "Do you wish to edit.." questions and all of the fields are live for editing. 

Given we are working with existing biological monitoring site data, I'm struggling to find a way around this. I tried setting a calculation on the update toggle fields to set the values to 'No' but the user has to click refresh buttons for each of the questions for them to revert back to 'No.'

It seems that my only option is to write a script that resets the "Do you wish to edit..." questions back to 'No' after survey data is submitted. Or, is there an easier way to accomplish my goal? I'd love to have the edit yes/no questions set up so that they do not connect with the feature class at all. Would that be possible? 

 

 

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Notable Contributor

You can put if statements in the read only column, no need to use regex.  (There is a drop down but you can still just type in there)  I do this and it works for me.  Then the if should refire better based on your Yes/No question.  if(somefield = 'yes', 'yes', '')  the relevant column is just a true false I think so even a 0/1 works.

I would consider using Collector for the known info instead though.  You can use the pop up to control which fields they can edit if they need to.  Use a URL to pass an id to over to the collection form and relate them all together.  Like you said its dangerous to have all of that in to form for editing.

Hope that helps.

View solution in original post

0 Kudos
3 Replies
DougBrowning
MVP Notable Contributor

You can put if statements in the read only column, no need to use regex.  (There is a drop down but you can still just type in there)  I do this and it works for me.  Then the if should refire better based on your Yes/No question.  if(somefield = 'yes', 'yes', '')  the relevant column is just a true false I think so even a 0/1 works.

I would consider using Collector for the known info instead though.  You can use the pop up to control which fields they can edit if they need to.  Use a URL to pass an id to over to the collection form and relate them all together.  Like you said its dangerous to have all of that in to form for editing.

Hope that helps.

0 Kudos
Strahanjen
Occasional Contributor

Thanks, Doug. That is a wise suggestion to use Collector for editing the known site info. Do you know if Collector can sync information if two different users view and edit different attributes for a particular site? An example: Someone in the office may edit landowner information for the survey site, while someone in the field may edit parking and access instructions. Some areas do not have a good signal, so folks need to work offline and sync updates later. We had a case where two different people edited the same survey site using Survey123 and the second record overwrote the first one. I need to do what I can to prevent this from happening. Maybe moving to Collector for site information edits would be better? And then just use Survey123 for the field data collected at each site? 

0 Kudos
DougBrowning
MVP Notable Contributor

If both users are offline then usually the last one in wins.  123 used to just send changes to the service but now it does all fields I think.  I would think Collector is the same way not sure.

Not much you can do about this unless the 123 team has some ideas.

0 Kudos