Using Calculations to Prepopulate answers when opening Survey from the Inbox

540
7
Jump to solution
07-01-2019 06:21 AM
Highlighted
New Contributor II

Hi - I've created a Survey from a Feature Service using Survey123 Connect.  The Feature Service comprises a point Feature Layer with a Related Table.  The fields/questions within the Related Table sit within a Repeat. I'm trying to 'automatically' pre-populate fields (Base Score, Compliance Score, Total Score and Frequency) in the parent Feature Layer (using a Calculation) with values from fields in the Related Table – here is a simplified mock-up:

It works fine in Survey123 Connect ‘Preview’ and it works fine when I open via ‘Collect’ in the Survey123 Field App.  However, when I open the survey from the Inbox of the Field App, the 4 fields with Calculations in the Feature Layer get a green refresh button which the user must click to run the Calculation (they don't update automatically):

Do you know if it’s possible get these fields to update automatically without having to click the refresh buttons?

Thanks

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
New Contributor II

Hi - I managed to come up with an option for this using Doug's suggestion of using Calculate and Note type questions - thanks to Doug and James for their input!  This is my revised mock-up of the form:

I changed the fields in the parent Feature Layer to "Calculate" type questions, which means they're not visible on the form.  However, the calculations on these fields now fire automatically, no need for the user to press a refresh button.  The two fields that I do need to show on the form (next_date_note and previous_date_note) are added as "Note" type questions with basic Calculations on them to update based on the (now hidden) Calculate fields ( Next_Date and Last_intervention).

Hope that makes sense and is useful to someone else in the future.

Thanks,

Mike

View solution in original post

7 Replies
Highlighted
Frequent Contributor II

Which version do you have?  This was a known bug in 3.3 I think.  3.5 just came out last Friday.  Try that.  I would update connect and the app as there are a ton of fixes.

Highlighted
New Contributor II

Thanks for the response Doug.  I'm using version 3.3.51 Connect and version 3.3.26 Field App.  I'll try upgrading as it sounds like I might be using the version with the bug.

Reply
0 Kudos
Highlighted
New Contributor II

Morning - I tried upgrading S123 Connect (to 3.5.157) as well as the Field App (to 3.5.164).  Unfortunately still getting the refresh buttons when the form initially loads...

But unlike previous, once I've pressed the refresh buttons once, the fields do start to work automatically, which is an improvement.  I was reading through the online docs in relation to Prepoulating answers and saw this:

This is what's happening, but the buttons appear when the form loads rather than after a "manual edit".  It's like the app treats existing attribute data in the point Feature Layer as a "manual edit".  Only happens when opening the survey from the Inbox, opening an empty form via the Collect option is fine.  

Do you have any further thoughts?

Thanks,

Mike

Reply
0 Kudos
Highlighted
Frequent Contributor II

I think what you said "It's like the app treats existing attribute data in the point Feature Layer as a "manual edit". is correct.

Do these need to be editable?  If you change to a read only Note field it may work like you want or a calculate if they do not need to see it.  I also wonder of you had a calculate field type then a Note that just used the calculate field value if that would do it.  Read only does not have the refresh button I think.

 

I never use the inbox (I use colletor url passes instead) so I am not positive.

Sorry I can't help more.

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Mike,

As Doug indicates, Survey123 is conservative of existing values when opening from the Inbox.  The value present is compared to the value the calculation would generate; if they are different, the assumption is that the data has been manually edited in the past and the calculation is set to be inactive, retaining the original value.  The recalculation button will reactivate the calculation.

Reply
0 Kudos
Highlighted
by
Occasional Contributor III

Is there a way to force a recalculate?  I would like a date field to be updated with the current date every time it is submitted from the inbox. 

Basically I have a filter on the Inbox to filter out current_month.  So when a record is submitted it gets updated with current date, thence removed from the inbox.  It will reappear the next month and so on.

Reply
0 Kudos
Highlighted
New Contributor II

Hi - I managed to come up with an option for this using Doug's suggestion of using Calculate and Note type questions - thanks to Doug and James for their input!  This is my revised mock-up of the form:

I changed the fields in the parent Feature Layer to "Calculate" type questions, which means they're not visible on the form.  However, the calculations on these fields now fire automatically, no need for the user to press a refresh button.  The two fields that I do need to show on the form (next_date_note and previous_date_note) are added as "Note" type questions with basic Calculations on them to update based on the (now hidden) Calculate fields ( Next_Date and Last_intervention).

Hope that makes sense and is useful to someone else in the future.

Thanks,

Mike

View solution in original post