Using Calculations to Prepopulate answers when opening Survey from the Inbox

2838
8
Jump to solution
07-01-2019 06:21 AM
MikeCottrill1
Esri Contributor

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

0 Kudos
1 Solution

Accepted Solutions
MikeCottrill1
Esri Contributor

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

8 Replies
DougBrowning
MVP Esteemed Contributor

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.

MikeCottrill1
Esri Contributor

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.

0 Kudos
MikeCottrill1
Esri Contributor

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

0 Kudos
DougBrowning
MVP Esteemed Contributor

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.

0 Kudos
JamesTedrick
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.

0 Kudos
TL2
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.

0 Kudos
MikeCottrill1
Esri Contributor

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

by Anonymous User
Not applicable

Hi @MikeCottrill1 @TL2 @DougBrowning,

Just letting you know we have recently updated the 3.14 beta builds on the Early Adopter Community and the next release will include major improvements to the expression calculation engine, new calculation modes, improvements to loading relevant questions and repeats, and other fixes to repeats, nested repeats and repeat count. With these improvements we see faster loading surveys, increased stability, less crashes and ability to optimize calculation workflows.

The issue you reported above can now be solved using the new calculation modes available in the latest 3.14 beta builds, where you can set calculations to always run, be manual or automatically run, as they have always. This new feature as well as improvements to how and when expression run, shoudl resolve many of the issues you have identified previously.

Please refer to this blog post for more details: https://community.esri.com/t5/arcgis-survey123-blog/arcgis-survey123-3-14-beta-now-available-for/ba-...

Direct link to EAC announcement: https://earlyadopter.esri.com/project/article/item.html?cap=e69ef91f45744b98882c651f7b518eb7&arttype...

Regards,

Phil.