Map Viewer Forms Calculated Field

1222
5
Jump to solution
03-09-2023 10:27 AM
Labels (1)
LeilaJackson1
Occasional Contributor III

Hello -

I have a hosted feature layer in ArcGIS online, and I am creating a form in the new Map Viewer that will be pulled into Experience Builder for editing data. I would like to calculate a field, based upon values entered in two previous fields. 

TEST_TOT_SCORE_DOUBLE = TEST_SCORE_SHORT + TEST_PAR_DOUBLE

But I cannot get the calculated field to calculate. I am not sure if I have my Arcade expression wrong (I am very new to Arcade) or if its related to one field being short and one being double, and the calculated field double, or something else. Below is my Arcade expression. 

LeilaJackson1_0-1678386264976.png

Many thanks in advance,

Leila

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Teresa_Blader
Occasional Contributor III

If there is no error in the arcade editor and the value equals what it should (look at objectiD 1 in your table), the arcade is correct then... I don't think you have to worry about that. When you build the form, does it show that the field is based on a calculation? 

Teresa_Blader_4-1678474775140.png

 

Below is an example adding short (integer) + double = double.  and double +double = integer. Hit Tab to calc. Arcade doesn't seem to care much that it's calculated with multi types. 

Teresa_Blader_2-1678474498153.png

Teresa_Blader_3-1678474654558.png

 

 

 

Teresa Blader
Olmsted County GIS Specialist

View solution in original post

5 Replies
MichaelCharpentier1
New Contributor

I think you need a return statement.  I'm new to this also.  I believe the semicolons are also needed. Here's code I'm testing that seems to work:

var threex = $feature.HAltWght * 3;
return threex;
0 Kudos
Teresa_Blader
Occasional Contributor III

The nature of Arcade allows you to do the simple equations without setting variables. 1+1 will return 2; 1+A will return 1A

Ex. Long+Double = number

Teresa_Blader_0-1678403276342.png

 

My question is, what does return when you click "Run" in the Arcade editor? Does it say "null" or "error"? That would help identify what is going on.

 

Teresa Blader
Olmsted County GIS Specialist
0 Kudos
LeilaJackson1
Occasional Contributor III

Hi Teresa -

Thanks for your reply. When I hit run it appears to run without error and returns a value - see snapshots below. But when I got to edit, it does not update the Total Score when I update either of the 2 fields, or both.

LeilaJackson1_0-1678455419005.pngLeilaJackson1_1-1678455438077.png

LeilaJackson1_2-1678455600918.png

 

Best,

Leila

 

 

0 Kudos
Teresa_Blader
Occasional Contributor III

If there is no error in the arcade editor and the value equals what it should (look at objectiD 1 in your table), the arcade is correct then... I don't think you have to worry about that. When you build the form, does it show that the field is based on a calculation? 

Teresa_Blader_4-1678474775140.png

 

Below is an example adding short (integer) + double = double.  and double +double = integer. Hit Tab to calc. Arcade doesn't seem to care much that it's calculated with multi types. 

Teresa_Blader_2-1678474498153.png

Teresa_Blader_3-1678474654558.png

 

 

 

Teresa Blader
Olmsted County GIS Specialist
LeilaJackson1
Occasional Contributor III

Thanks Teresa -

I did not have the expression checked so it did not show up as a calculated field. Not very intuitive. Thanks for pointing that out. It is working now.

Best,

Leila