PROBLEM

Running an Arcade script fails in ArcGIS Online

Last Published: March 31, 2021

Description

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:
Execution Error:Runtime Error:
Error:   
Parse Error:Line <line number>: Unexpected number
Parse Error:Line <line number>: Unexpected number
Error:   
Parse Error:Line <line number>: Unexpected identifier
Parse Error:Line <line number>: Unexpected identifier
Error:   
Parse Error:Line <line number>: Unexpected token <operator>
Parse Error:Line <line number>: Unexpected token <operator>
Error:   
Parse Error:Line <line number>: Invalid left-hand side in assignment
Parse Error:Line <line number>: Invalid left-hand side in assignment
Error:   
Parse Error:Syntax Error: Binary Operator not recognised <operator>
Parse Error:Syntax Error: Binary Operator not recognised <operator>
Error:   
Execution Error:Runtime Error: Assignments not be made in logical tests
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
Execution Error:Runtime Error: Operator <operator> not allowed in this context. Only <operator> can be used with boolean, and - with a number

Cause

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.

The Expression box containing the Arcade script that includes the incorrect use of the Assignment operator.

In the second example, the script contains an incomplete ‘Logical and’ operator, as shown in the image below.

The Expression box containing the Arcade script that includes the incomplete the ‘logical and’ operator in ArcGIS Online.

In the third example, the script contains a typo after the 'Less than' operator, as shown in the image below.

The Expression box containing the Arcade script that includes a typo after the 'Less than operator' in ArcGIS Online.

Solution or Workaround

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 Expression box containing the modified Arcade script to include the correct and complete operators.

The image below shows the Office_Size field is populated after successfully running the Arcade script.

The attribute table showing the populated Office_Size field after successfully running the Arcade script.

Article ID: 000025202

Software:
  • ArcGIS Online

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options