Select to view content in your preferred language

Have a repeat in survey123 default to last record entered

4717
15
01-21-2021 08:28 AM
TomBaldvins
New Contributor

Hello,

I am creating a form in survey123 that records plant species along different transects. It would speed up productivity a lot if the survey could default to the last species selected. Has anyone set up a survey like this before? I am trying to capture the last species collect in a text field outside the repeat, but I am getting the error below. I am attaching the survey below. 

Thank you!

TomBaldvins_0-1611246410876.png

 

Tags (2)
15 Replies
LukeGilner1
Frequent Contributor

Can you explain to me like I'm 5 years old how to setup the javascript file? 🙂  I've never created a javascript file, but this looks like the solution I need.  I want to pull the 18 answers from the previous repeat into each subsequent repeat.  I know the .js file needs to be stored in a "scripts" folder in the survey directory.

Go Pack Go!

DougBrowning
MVP Esteemed Contributor

Oh its been years now but check out this post  https://community.esri.com/t5/arcgis-survey123-blog/extending-survey123-smart-forms-with-custom-js/b...

That is a lot to pull though and it may be slow calling javascript 18 times.  Seems weird to need that many so I would be curious the use case on that.  Using arcade after that fact may be easier.

We got this on Sunday night!

0 Kudos
LukeGilner1
Frequent Contributor

Thanks Doug!  I'll take a look through this.  I'd have to upgrade Survey123 to see the new Script tab first and then rebuild all my excel forms.  I'd like to pull 18 answers because each repeat (inspection) has a series of questions with Acceptable, Needs Improvement, Corrected-Acceptable as choices.  It'd be nice if the user could see that the previous inspection was set to Needs Improvement on a certain question to help them remember that the item needs to be corrected on the ground and then changed to Corrected-Acceptable in the new inspection, if appropriate.  Is there a better way to do this with Arcade?

I think the game will be a nail bitter.  But I hope they blow them out!

0 Kudos
DougBrowning
MVP Esteemed Contributor

Well you could pull the last inspection data via arcade in Field Maps then pass that to 123.  We use field maps to find out way there.  18 is still a lot but I have done up to like 12 I think.  You could also use Arcade to only pass say a list of items that did not pass the last time.  That would be less for the person to review and less space on the form.  Like a what to watch out for note basically.  Could work out nice.  This assumes 1 form per inspection vs a main and then each inspection is a repeat.  I like to have one form per inspection so I get all the editor tracking, GPS, etc.  You could also display it in Field Maps before they click but not as slick.  

I think that is what you mean.

0 Kudos
LukeGilner1
Frequent Contributor

I came up with a roundabout way to achieve this.  I added a hidden "score" to each question within the repeat.  Acceptable = 0, Needs Improvement = -1, Corrected-Acceptable = 5.  Then outside the repeat I summed each "score" for each question.  Inside the repeat I also added a Note with red font for each question that basically flags this question was determined to Need Improvement.  The Note is only relevant if the sum of the "score" is Less than 0, so it kind of tells you what the previous response was.  There may be times that subsequent repeats will remain as Needs Improvement for several inspections in a row, so that is why the Corrected-Acceptable = 5, to make sure the sum will eventually be 0 or greater so that the Note no longer is relevant.  Just thought I'd share.  Thanks for your help.

DougBrowning
MVP Esteemed Contributor

I am with the AIM team!  Send me a DM and I will just give you the form.  No need to reinvent it.

0 Kudos