PROBLEM
In ArcGIS Online, it is possible to build and run an Arcade script on a layer using the Calculate option in the layer’s attribute table. In some instances, attempting to run an Arcade script fails and returns one of the following error messages in the Results pane:
Error: Execution Error:Runtime Error:
Error: Parse Error:Line <line number>: Unexpected number
Error: Parse Error:Line <line number>: Unexpected identifier
Error: Parse Error:Line <line number>: Unexpected token <operator>
Error: Parse Error:Line <line number>: Invalid left-hand side in assignment
Error: Parse Error:Syntax Error: Binary Operator not recognised <operator>
Error: Execution Error:Runtime Error: Assignments not be made in logical tests
Error: Execution Error:Runtime Error: Operator <operator> not allowed in this context. Only <operator> can be used with boolean, and - with a number
This issue occurs if the script contains missing or incorrect operators.
In this article, an Arcade script is used to populate the ‘Office_Size’ field based on the ‘Number_of_Employees’ field values. The 'Office_Size' field is populated with 'Small' for less than 10,000 employees, 'Medium' for 10,000 to less than 20,000 employees, and 'Big' for at least 20,000 employees.
In the first example, the script incorrectly uses the 'Assignment' operator instead of the 'Greater than or equal' operator in a logical script, as shown in the image below.
In the second example, the script contains an incomplete ‘Logical and’ operator, as shown in the image below.
In the third example, the script contains a typo after the 'Less than' operator, as shown in the image below.
Modify the script to use the correct operator(s) in the Calculate Field window, and click Test to verify the script before clicking OK to run the script.
The image below shows the correct script with the 'Greater than or equal' operator (>=) and the double 'Logical and' operator (&&) instead of '=' and ‘&,’ and the script without the typo after the 'Less than' (<) operator. Refer to ArcGIS Arcade: Operators for more information. Clicking Test to verify the script does not return any error message.
The image below shows the Office_Size field is populated after successfully running the Arcade script.
Get help from ArcGIS experts
Download the Esri Support App