Survey123 calculations not working in edit mode

4223
14
04-09-2021 08:57 PM
KimberlyMcCallum
New Contributor III

Hi All, 

I am using the embed widget in Experience Builder to embed surveys so that I can click on a map feature and open a survey built on the service (in edit mode). Basically, I adapted this example of a QA/QC workflow using a Dashboard to Experience Builder (https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-embedding-a-survey...). This just uses the URL parameters and the Global ID to open the survey for editing. The app and survey looks great and I am able to submit data BUT the calculations are not working in the embedded survey! 

After some investigation, I have figured out that the issue seems to be with calculations in edit mode. The calculations work for new records; however, when I open an existing record to update it (in edit mode), I see the 'Recalculate' button; however it does not work! 

Admittedly, the calculation is a bit complicated and awkward as I'm trying to calculate Risk from a risk matrix (see screenshot). Here is the calculation: 

 

if(((selected(${DamageOrLossProbability},'VeryLikely') and selected(${ConsequenceMagnitude},'Major')) or 
    (selected(${DamageOrLossProbability},'VeryLikely') and selected(${ConsequenceMagnitude},'Moderate')) 
    or (selected(${DamageOrLossProbability},'Likely') and selected(${ConsequenceMagnitude},'Major'))), 
    'VeryHigh', if(((selected(${DamageOrLossProbability},'Likely') and selected(${ConsequenceMagnitude},'Moderate')) or 
    ((selected(${DamageOrLossProbability},'Possible')) and selected(${ConsequenceMagnitude},'Major'))), 
    'High', if(((selected(${DamageOrLossProbability},'Unlikely') and selected(${ConsequenceMagnitude},'Major')) or 
    (selected(${DamageOrLossProbability},'Possible') and selected(${ConsequenceMagnitude},'Moderate'))), 'Intermediate', 
    if(((selected(${DamageOrLossProbability},'VeryLikely') and selected(${ConsequenceMagnitude},'Minor')) or 
    (selected(${DamageOrLossProbability},'Likely') and selected(${ConsequenceMagnitude},'Minor')) or 
    (selected(${DamageOrLossProbability},'Possible') and selected(${ConsequenceMagnitude},'Minor'))) or 
    (selected(${DamageOrLossProbability},'Unlikely') and selected(${ConsequenceMagnitude},'Moderate')), 'Low', 'VeryLow'))))

 

Thanks in advance,

Kim

14 Replies
JasminePrater
Occasional Contributor II

What I did to solve this issue was to remove the read-only status from those fields.  When it's set to read-only, it doesn't give you an option to manually update them, so they automatically calculate each time.  However, when you remove that requirement, you get a button that allows you to choose whether to keep the original value or recalculate.  It's a little backward, but it worked for me.  The only downside is that you get a large Recalculate button for that question, but at least it saves the original result.

chelynnes
New Contributor III

chelynnes_0-1643059083891.png

The yellow fields are the ones the customer can see and are not allowed to be manually calculated. 
Total time is calculating 2 hidden fields. Even when I took the read only off of the Total, it still didn't calculate.

0 Kudos
JessicaJThompson
Occasional Contributor II

Hi All,

I am having the same issue. Unfortunately I cannot make the question a read only because it calculates three different options based on prior selection. Two are "defaults" and the third calculation is a blank - allowing the user to make a manual selection. 

I am going to try to follow the bug and see if we can get some progress on it. 

Thanks for all of the ideas and solutions.

-Jessica

0 Kudos
mwartman_grey
New Contributor III

I have the same issue. 

I am trying to open a survey in edit mode, and have a date/time field automatically update on an existing record. However, I still see the recalculate button in the web form and the old date is displayed. In Survey123 Connect, the [IssueDate] field is set to calculate to =now(). I've tired to recalculate other calculate fields and none of them will auto-calculate when the form is opened. Web form was published using the latest version of Survey123 Connect (3.16)

Here is my url with parameters: 

https://survey123.arcgis.com/share/167df9fb24694a0da5c66b5bdeea1dac?mode=edit&globalId=70268755-16a8...

I believe I correctly followed the syntax from this blog post. I also noted that the following error is showing in the browser console: 

forcerecalculateerror.PNG

 

 

0 Kudos
mwartman_grey
New Contributor III

Updated January 9, 2023. The url parameter ?forceRecalculate is now ?recalculate

0 Kudos