Select to view content in your preferred language

Help with Arcade expression for inventory management

343
1
10-31-2022 10:19 AM
EQRAdmin
New Contributor

Hi community!

I am trying to use ArcGIS Field Maps for viewing inventory of different groups of plants. I have set up an expression in Arcade in Field Maps, and the expression aims to calculate the current number of plants in an area, taking into account changes in its inventory. When someone adds or pulls plants, they will enter the number added or pulled into a field titled "Change" in the form of a positive or negative integer. When someone creates a new group of plants, they will put the original number of plants that they started with.

I am extremely new to Arcade so am just figuring this all out. I tested this expression and received no error messages, but when I try to create features in Field Maps, the whole form freaks out and freezes and the calculated value shows random numbers. 

Expression:

 

if (IsEmpty($feature["Current_Number"])) {
return $feature["Original_number"];
} else {
return Sum ($feature["Current_Number"], $feature.Change);
}

 

If anyone could identify a possible error here, or can think of a better approach, I'd appreciate it so much. Thank you!

0 Kudos
1 Reply
jcarlson
MVP Esteemed Contributor

Hard to say without access to the data itself for testing, but I would guess there's something wrong with the Sum line? That function will be looking for numbers, so if one of your values is a non-numeric string, you'll get a "NaN" response.

Can you confirm the field types you're working with in the data and on the form?

- Josh Carlson
Kendall County GIS
0 Kudos