Select to view content in your preferred language

Model failing to add text into calculated string field

543
1
Jump to solution
10-01-2019 10:49 AM
MalcolmLittle
Regular Contributor

Hello,

In modelbuilder, I am trying to create a text field that will contain the first five characters of a feature class name. The model is as follows:

The adding of the field runs okay for each feature class that needs it, but the calculate field fails to populate the field with the leftmost five characters - the field remains empty. Here is the Calculate Field parameters:

Perhaps my VBscript code is off, yet no errors are thrown. I end up with empty SID fields for each feature class needing them populated with the leftmost 5 characters.

0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Esteemed Contributor

You need to use a string literal. Try this, VBScript will see something like: Left("test_poly", 5) at runtime:

Left("%Name%", 5)

or better yet, use the Python parser

"%Name%"[:5]

View solution in original post

1 Reply
curtvprice
MVP Esteemed Contributor

You need to use a string literal. Try this, VBScript will see something like: Left("test_poly", 5) at runtime:

Left("%Name%", 5)

or better yet, use the Python parser

"%Name%"[:5]