ERROR
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
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.
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.
The image below shows the ModelBuilder function runs successfully.
Get help from ArcGIS experts
Download the Esri Support App