I am having trouble getting calculations to work in my form. The calculation occurs in a related record that is opened via the inbox. The source for my form is a hosted feature layer in ArcGIS Online. The fields in question are all part of the same record. The Contract field (part of the related record) in my survey has a value when it is opened in Survey123. The values come from a choice list: 1: Asphalt Base road, 2: Concrete Base Road, 3: Sidewalk, 4: Grass. There are four select_one fields that I want to be populated with an answer based on the this contract type. These fields can have an answer of -1: Not Applicable, 0: No, 1: Yes. The contract type will determine how each of these will have their answer calculated. Eventually, I am going to hide the fields that don't fit with a certain contract type. For example, a grass cut does not have vehicle detectors and so would have an answer of -1 (Not Applicable) and be hidden for this contract type. When a field needs an answer, I want each select_one question to not have an automatically calculated answer because I need the user to make a choice. If they don't choose one, it will be caught when then try to submit the form because these fields are required. As I understand it, the calculation should occur every time an answer is changed on my form. That doesn't seem to be happening. When the survey is opened and a field changed, the calculations don't appear to run. If I click the refresh arrows next to the select_one fields nothing appears to happen. I attached my form. Can anyone find anything wrong with my formulas? Am I misusing the calculation column? What am I missing? Thanks.
Solved! Go to Solution.
Hi Jim
Just a quick fix for this: if(${Contract}=1, "Success", "Fail") - don't put a space between the if and the (
Cheers
John
Hi Jim
We have made a change to the way that the inbox and drafts do calculations, as a result of user feedback and bugs raised. Essentially, users were unhappy about the fact that when a survey was loaded/opened, calculations would fire and values would be overridden - even if the user had manually typed something in. To make the behavior more predictable, on load from the Inbox or Drafts, the survey values will match whatever was entered in the form when it was submitted/saved - i.e. no calculations will run.
However, when you update the values in the form - calculations should be triggered if they reference another question that has changed. This looks to be a bug and we will get this looked at. For the time being, the user will need to manually recalculate if working from drafts/the inbox.
Thanks
John
Thanks for the reply and verifying the calculation trigger bug. Is this just limited to drafts and inbox surveys?
I created a simple form with just a few fields to replicate the behavior from my mark out form. When I click a contract type I want the select_one questions to become -1, 0 or 1. When I select a contract type, nothing happens to any of my questions. I changed one question type to just a text question to see if I could just have a text answer populated in the question and see this string in the question when my form opens:
SyntaxError: Expected token `;' in expression: if ( /Form_6/Contract =1,"Success", "Fail")
Is this related to the calculation trigger bug, something different or am I doing something wrong?
Thanks for the help.
Hi Jim
This sounds different. Please share the survey and steps and I'll take a look.
Thanks
John
Hi John,
Attached are the two surveys where I am experiencing issues. The Paving Cuts-First Inspection survey opens from the Inbox. The Repair Location details is a read only group that provides our inspector with information about the repair and is the parent record to Paving Cut Details. The Contract question is set in the office prior to the inspector performing this inspection so when he opens the survey, it already has a value. My intent is for the Contract question to automatically populate answers for the Vehicle Detector, Pavement Markings, Reuse Curbing and Reuse Pavers questions. I also will have these same survey questions be hidden based on the selected contract type. I have kept them visible thus far to ensure the answers I want are calculated correctly. The table below shows how I want the answers to be determined based on the selected contract type.
Asphalt Base Road | Concrete Base Road | Sidewalk | Grass | |
---|---|---|---|---|
Vehicle Detectors | No Default Answer | No Default Answer | Not Applicable (Hidden) | Not Applicable (Hidden) |
Pavement Markings | No Default Answer | No Default Answer | Not Applicable (Hidden) | Not Applicable (Hidden) |
Reuse Pavers | Not Applicable (Hidden) | Not Applicable (Hidden) | No Default Answer | Not Applicable (Hidden) |
Reuse Curbing | No Default Answer | No Default Answer | No Default Answer | Not Applicable (Hidden) |
I am trying to ensure that there are answer to these survey questions when they are not visible to the inspector and force them to make answers when they are visible.
There are several questions following these that will have similar logic applied but I haven't added that as I haven't gotten it working for these fields yet. At the bottom of the survey is a third related table that will store bid items related to the work done for the parent Paving Cut record. The calculations I have here work as expected.
Also attached is a survey called From 6. This is a simple Survey that just has the Contract type and four questions and is not tied to my feature service in AGOL nor does it have any related records/repeats to deal with. I just wanted to see if I could get the calculations to work based on a selection I make and received the same results as above.
Thanks for your help.
Hi Jim
Just a quick fix for this: if(${Contract}=1, "Success", "Fail") - don't put a space between the if and the (
Cheers
John
That's it? One lousy space? I am glad it was something simple. I should have noticed that based on the other if statements in my sheet.
Thanks for the help!
Is there a way around the calculation refresh/update for inbox items?
I have a field (chg_code) that tracks whether its a new site or an edit site.
I have a calculation that reads a different attribute (site_id )and if the attribute has a value greater than 0, the site is considered edited and receives a chg_code value of 2. If its a new site it receives a value of 1. Its that easy.
However, the way i see it, users are going to need to hit the calculate button if they make an edit to the feature. And people will naturally forget to do this.
How would you suggest moving forward?
Also have this question