What is up with the Update Button (Calculate Button) on an edit?

2391
6
02-18-2021 11:32 AM
ScottLehto1
New Contributor II

I noticed during an edit of a feature in Survey123, i need to click the update button for fields i have a calculation for.

I have the button highlighted in Picture below.

ScottLehto1_0-1613676555583.png

 

Here is my Calculation:

if(${site_id} > 0,'2', '1')

 

When creating a new site, the calculation runs automatically, but during an edit, the user needs to click on the button to run the calculation.

 

This is a kinda lame feature.

 

How do i get past it? I just want edited records to have the same behavior as new records in the Survey123 form.

 

0 Kudos
6 Replies
IsmaelChivite
Esri Notable Contributor

Hi @ScottLehto1 

When you are creating a new survey, calculations trigger automatically whenever a question has never been manually changed by the end user. When a user manually enters a value in a calculated question, the calculation stops executing because otherwise the calculation could overwrite the calculated value.

For the convenience of the end user, the calculation refresh button appears on the side in case the user decides to trigger the calculation again.   That is the meaning of the button you see.

When a record is loaded from the Inbox, there is no way for the Survey123 app to know if a value in a question comes from user input or from a calculation. For this reason, the behavior is not to trigger calculations to avoid data loss. The refresh calculation button is shown, again, in case the end user decides to trigger the calculation for a particular question.

At this moment, there is no way in XLSForm to indicate that a question calculation should be triggered always even if the record comes from the Inbox or the end-user has manually entered a value. 

Please check the Survey123 Tricks of the Trade: Calculation modes to learn how you can force a calculation to always execute, including when records are loaded in the inbox.

 

 

0 Kudos
FedericoVelez
New Contributor

A client of mine has the same requirement but they have almost all their calculations on hidden fields (so that the user can't mess them up) which means that the button is not available and making the fields visible is a no go for them.

Is there a way (perhaps using scripts) to force the updating of calculations of features comming from the inbox?

0 Kudos
IsmaelChivite
Esri Notable Contributor

As of 3.12 it is not possible to force the calculation of a question in edit mode when the record is loaded in the form. In 3.13, only for the Survey123 web app, we will introduce a new parameter that lets you force recalculations when using mode=edit.

recalculate=field:questions,field:question2

This remains as an unresolved limitation in the Survey123 field app.

 

FedericoVelez
New Contributor

Well given the fact that we are already using URL parameters to edit existing data from the web form this fits amazingly well into the established workflow with minimum changes. We'll implement the new parameter and get back to you.

Gracias

0 Kudos
Scott_Sambell
Occasional Contributor

Ismael, this is exactly what i was looking for with the embedded edit mode webform i am building.  Thanks so much!

 

Scott
0 Kudos
Adam_Bourque
Occasional Contributor

Hey Ismael, is this still an unresolved limitation for the S123 field app? As far as the recalculate option, wanting the values to overwrite existing calculated values.

 

Looks like you all added the function "calculationMode=always" for under parameters which seemed to do the trick. Thank you all at the S123 team, you all continue to impress

 

Thank you

0 Kudos