0

I'm trying to replace the text in a field to build a label expression. The field I'm using is called [Organizatio] and it holds the school's name. What I want is to tell ArcMap that when that name includes 'Central School District' - change it to "CSD."

This is what I have. ArcMap says it's valid but it does not make any changes.

enter image description here

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked May 9, 2018 at 17:48
2
  • 2
    You need to define the function without the field name in code block, in the bottom block you can use the function as FindLabel(!Organizati!). Check documentation for more information Commented May 9, 2018 at 18:14
  • I'm not sure I understand what you're telling me. I'm doing this in the label expression window. Parameters have to be passed as shown. Commented May 10, 2018 at 18:52

1 Answer 1

4

As I mentioned in commentaries:

Use in pre-logic script code block:

def FindLabel(field):
 string = field
 newstring = string.replace('Central School District ', 'CSD ')
 return newstring

In field definition (test2 is the object field):

FindLabel( !test2! )

enter image description here

Result:

enter image description here

test1 and test2 had the same values initially

answered May 10, 2018 at 19:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.