I have a feature service with a parent table and several related child tables.
Each child table supports a part of a weeks long workflow and has its own form that references the feature service. Responses entered in the child tables update fields in the related parent. I want this to happen in the background, however I can't seem to modify parent fields without manually refreshing the calculation.
If a create a new record with this form the calculations are automatic, but updating the parent requires clicking on this button.
For example:
Here is a simple form with a repeat:
type | name | |
---|---|---|
geoPoint | location_point | The point location |
dateTime | event_date | The date the point was collected |
begin repeat | child | The child table |
integer | entry | Some data entry that triggers a change to the parent |
end repeat | ||
text | event_closed | The event was closed |
The first two are collected in the initial collection form:
type | name | |
---|---|---|
geoPoint | location_point | |
dateTime | event_date | |
hidden | event_closed |
The repeat and the "event closed" are collected in a child form:
type | name | |
---|---|---|
geoPoint | location_point | Read only (used for reference) |
dateTime | event_date | Read only |
begin repeat | child | The child table |
integer | entry | Some data entry |
end repeat | ||
calculate | event_closed | if(sum(${entry})>1,"yes","no") |
In the child form "event_closed" is invisible because it is set to a calculation. It should populate the parent field with either "yes" or "no" depending on the data collected, but it is not working that way.
When I expose the field in the form by changing from "calculate" to text I see the refresh button
which I have to manually press for the calculation to take place.
Is there any way to force this calculation so it doesn't require user input?
Survey123 - 3.6.153 (android and PC)
Survey123 Connect - 3.6.137
ArcGIS Enterprise 10.7.1
Solved! Go to Solution.
I had the same issue.
The calculationMode parameter entered in the bind::esri:parameters column controls when calculations in questions are calculated, for example, calculationMode=manual. There are three supported values:
This link explains how to calculate it:
Hi Benjamin,
Calculations are done automatically. It may be helpful if you could share the XLSX file so that we could see in more detail what is occurring. That being said, once the value of a question differs from the calculation, re-engaging the calculation requires pressing the recall button. This also occurs when loading a form from the drafts or Inbox; if a value is null, for example, it will stop updating based on the calculation.
Hi James,
Is there a way to recalculate an entire form?
Like you mention above because I use the inbox to open many of the forms (editing existing records rather than creating new ones) I have to press the re-calculate button for each field. I have six or so fields that have to be recalculated each time; it would be useful to be able to recalculate the whole form at once instead of having to recalculate each field individually.
Some context to what I am trying to do:
A technician collects a sample from the field and creates a record using Collector. Later the sample is examined in the lab and a lab technician fills in the rest of the information for that record. Many of the fields are calculated based on what the lab technician enters. Ideally these would calculate automatically even thought they are technically already "NULL" .
Thanks
Hi,
I found a work around to recalculate the whole form.
When you have conditions set in the "Relevant" column it resets the value and automatically runs the calculations on a field when the condition is met.
Notes:
1. This method should be used with caution because if the field does not meet the condition than any value that was already populated will be deleted and the value will be reset to null.
2. This doesn't work if the condition is immediately satisfied, e.g. if you set the condition to a static field. So I have a single question that I select "Yes" on and it updates the whole form.
If anyone find a better way I am happy to hear it.
I had some luck giving it a dummy if statement like if(somefield, calc, samecalc). You could maybe tie this to a time as well. Maybe if(starttime != now(),calc, calc) where start time is a build in field. Then basically you know they opened it again. today() may be better otherwise this may fire it a lot. Either way I worry a little if you are having too many fields recalc all the time it could slow the form.
Other way i use a lot is Arcade so it is always dynamic. If someone edits the data in a web map then 123 calc does not fire so this is safer for me. Depends on your workflow.
Yet another option is attribute rules that recalc the parent when the data is changed. I think you need a non hosted feature service for this to work however.
Not sure but it is an idea.
Thank you Doug,
No luck with the if statement, I think it has to do with there being an existing value (even if it is null). I am very open to other workflows to solve the problem. It is a hosted feature service in AGOL so I don't believe that you can set attribute rules -- but I will look into that.
How do you use Arcade? So far all I have read is that you can use it in popups and symbology but not to commit calculations; is there a way to use Arcade to automate the calculations? Manually doing field calculations would have limited utility for my workflow.
Thanks
Hey Benjamin, I'm not sure if you saw this month's blog/release notes, but the "recalculate" URL parameter was added.
Hi Benjamin,
I'm having a similar issue. Would you mind demonstrating where you implemented the relevant comment to force the calculation?
Thank you
I had the same issue.
The calculationMode parameter entered in the bind::esri:parameters column controls when calculations in questions are calculated, for example, calculationMode=manual. There are three supported values:
This link explains how to calculate it: