I was surprised that code line 4 failed to resolve field, even when I’m returning the internal field name from code line 1.

To resolve this, you have a couple of options:

Don’t use spaces in the Display Name in code line 1, which is preferred as you don’t want your field internal name to contain spaces that get converted to _x0020_ and make your life miserable trying to remember to add those characters every time you want to call the field.

In code line 3, instead of getting the field from web.Fields directly, use the following: