ERROR

ERROR 000539: File "<expression>", line 1, SyntaxError: invalid token

Last Published: February 23, 2022

Error Message

When creating a model with the ModelBuilder function in ArcGIS Pro using the Calculate Field tool and the output value of the Iterate Feature Selection iterator connected as an expression, the following error message is returned.

Error:   
ERROR 000539: File "<expression>", line 1 SyntaxError: invalid token
Error 000539

Cause

The error occurs because the output value of the iterator is used as an expression rather than an inline variable in the Calculate Field tool.

The tool has two outputs: Selected Features and group Value of the field for selected features, which could be used as an inline variable in other tools. Refer to ArcGIS Pro: Inline variable substitution for more information.

Solution or Workaround

To resolve the issue, define the Value of the Iterate Feature Selection as a Precondition of the Calculate Field tool and set it as an inline variable for calculating the field.

  1. Remove the connection between Value and Calculate Field.
Remove the connection
  1. Make a new connection by dragging the arrow from Value to Calculate Field.
  2. Select Precondition. Notice the connected arrow is dotted.
Make a new connection Notice the connection line is dotted
  1. On the ribbon, in the ModelBuilder tab, click Run.
In the ModelBuilder tab, click Run

The image below shows the ModelBuilder function runs successfully.

The ModelBuilder function runs successfully

Article ID:000027064

Software:
  • ArcGIS Pro 2 8 x
  • ArcGIS Pro 2 x

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