I have a simple calculation in a Calculate Field tool in modelbuilder. %Field Name% is a variable that references an actual field that is in the attribute table.
This is what the results look like:
I have been using inline variable substitution regularly and have never seen anything like this. If I double-click the field from the drop-down, instead of using '!%Field Name%!', it works as desired.
Does anyone know what is going on here and how to correct it?
Thank you,
Randy McGregor
Would it be possible to test the function without the exclamation points? I remember having an issue where the exclamation points were causing an issue, but I'm unfortunately no longer able to test and can only give suggestions!
Cody
That populated the field with the name of the field. I tried Arcade and had the same effect. I have no memory of ever having to clarify that I want the contents of the field, rather than it's name to populate reccords. I'm either having an end-of-year brain freeze, or something strange is going on. 'ParishXed3' is the name of the field.
If I select the field from the drop-down, it works fine:
Thanks for the suggestion. I'll give it a try.
Oookay, so I went back to python and put the "!" marks outside of the quote marks and that works. There's some trick to getting arcade to recognize that you are asking for the value within the field, rather than the field's name, but I don't know what it is.
This is a ModelBuilder evaluation-order issue, not user error.
Inline substitution (%Field Name%) is resolved before Calculate Field runs, but the expression itself is parsed later. The result is that the substituted value is treated as literal text, not a field reference — which is why you see the field name written into the row.
Don’t use inline substitution inside Calculate Field expressions. Always use the actual field token (!FieldName!) or resolve the expression first (e.g., with Calculate Value) and pass it in.
The %variables% and Calculate Field don’t play nicely together due to timing — explicit field tokens are the safe path.
Thank you very much for that explanation. Very interesting.
I did have luck with !'%field name variable%'! though. Keeping the explamation marks outside the quote marks worked. I think your advice will help with Arcade expressions. I'll give it a try.