<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Drawing Alert leads me to Labeling Expression error ? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1608184#M95178</link>
    <description>&lt;P&gt;I fixed it and it worked; however on line 2 which I am not sure about but I can see the Admin_Org has null and I don't know how to include it in the code ?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def FindLabel ( [TRAIL_NO], [ADMIN_ORG], [MANAGING_ORG], [TRAIL_NAME],[NATIONAL_TRAIL_DESIGNATION]):
    if [ADMIN_ORG].startswith('02'):
        s='.'
        if [ADMIN_ORG].startswith('0201'):
            return [TRAIL_NO][2:]
        else:
            if [TRAIL_NO]:
                return [TRAIL_NO]
            else:
                return "TRAIL_NO is null"&lt;/LI-CODE&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;expression&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 2, in FindLabel&lt;BR /&gt;AttributeError: 'NoneType' object has no attribute 'startswith'&lt;/P&gt;&lt;P&gt;And here is the screenshot for the field name here is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PROBERT68_0-1745341645327.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/130754iE3FE34CEA27845AD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PROBERT68_0-1745341645327.png" alt="PROBERT68_0-1745341645327.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Apr 2025 17:07:36 GMT</pubDate>
    <dc:creator>DEAF_PROBERT_68</dc:creator>
    <dc:date>2025-04-22T17:07:36Z</dc:date>
    <item>
      <title>Drawing Alert leads me to Labeling Expression error ?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1607362#M95108</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Before I dive into more detail. I have an issue with a layer that somebody wrote this expression into this labeling expression.&amp;nbsp; I have the Drawing Alert that tells me . I am trying to understand this and I am not sure how to fix it.&lt;/P&gt;&lt;P&gt;The layer I had was from an original layer came from the upper management and they did this for the whole country and I had to use it to clipped it to smaller area for our project.&amp;nbsp; &amp;nbsp;So when you clipped the layer , I believe some of the expression did not work in the label expression.&lt;/P&gt;&lt;P&gt;So here is the Expression from the Labeling section is what I have here from an original layer:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def FindLabel ( [TRAIL_NO], [ADMIN_ORG], [MANAGING_ORG], [TRAIL_NAME], [NATIONAL_TRAIL_DESIGNATION] ):
    if [ADMIN_ORG].startswith('02'):
        s='.'
        if [ADMIN_ORG].startswith('0201'):
            return [TRAIL_NO] [2:]
        else:
            return [TRAIL_NO].split(s,1)[0]
    elif [ADMIN_ORG].startswith('0919') or [ADMIN_ORG] .startswith('0922') or [ADMIN_ORG] .startswith('0903')or [ADMIN_ORG] .startswith('0913'):
        return [TRAIL_NO] [2:]
    elif [ADMIN_ORG] .startswith('0909') or [ADMIN_ORG] .startswith('0907'):
        return [TRAIL_NO] [2:].replace('-','')
    elif [ADMIN_ORG] .startswith('0904'):
        return [TRAIL_NO] [1:]
    elif [ADMIN_ORG].startswith('0915'):
         return [TRAIL_NO][4:]
    elif [ADMIN_ORG].startswith('08'):
       if [ADMIN_ORG].startswith('0805') or [ADMIN_ORG].startswith('0810'):
            return [TRAIL_NO].replace('TRBS','').replace('TR','')[1:]
       else:
            return [TRAIL_NO].replace('TRBS','').replace('TR','')
    elif [ADMIN_ORG].startswith('04'):
        if [ADMIN_ORG].startswith('0419'):
            return [TRAIL_NO] [1:]
        elif [ADMIN_ORG].startswith('0402'):
            return [TRAIL_NO][:3]
        elif [MANAGING_ORG].startswith('0402'):
            return [TRAIL_NO][:3]
        elif [ADMIN_ORG].startswith('040702') and [TRAIL_NO].startswith('32000.'):
            return [TRAIL_NO].replace('32000','').replace('.','')
        elif [ADMIN_ORG].startswith('040702'):
            return [TRAIL_NO][2:]
        else:
           return [TRAIL_NO][1:]
    elif [ADMIN_ORG].startswith('0303'):
        return [TRAIL_NO] [2:]
    elif [MANAGING_ORG].startswith('031204'):
        return [TRAIL_NO].replace('MT-','')
    else:
        return [TRAIL_NO].lstrip("0").replace('.', '-').replace('TER-','').replace('TRD','')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I have the clippped layer here and I have looked into the attributes and I can see some of the split it mention in the expression and yes I can see some of the numbers like this 157.2 or "Name of trail".456&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The Problem is the error that tells me&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Traceback (most recent call last):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "&amp;lt;expression&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "&amp;lt;string&amp;gt;", line 7, in FindLabel&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;AttributeError: 'NoneType' object has no attribute 'split'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I am clueless here and I am not sure what the line 7 is and I am not sure where to find it.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Please excuse my grammar here. I am deaf and I try my best&amp;nbsp; to understand how it works and it will help me to understand better down in the road should I came up the same thing in the future...&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Thanks GIS friends !&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I am in the VDI, Citrix, and ArcGIS Pro 3.3.4.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Apr 2025 14:57:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1607362#M95108</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2025-04-21T14:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing Alert leads me to Labeling Expression error ?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1607625#M95131</link>
      <description>&lt;P&gt;It's difficult to follow the logic of this code. When posting code (especially Python code, where indenting is important), please use the "&lt;A href="https://community.esri.com/t5/community-help-documents/how-to-insert-code-in-your-post/ta-p/914552" target="_self"&gt;Insert/Edit code sample&lt;/A&gt;" button.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Apr 2025 13:38:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1607625#M95131</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-04-21T13:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing Alert leads me to Labeling Expression error ?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1607632#M95132</link>
      <description>&lt;P&gt;Ok will do.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Apr 2025 14:00:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1607632#M95132</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2025-04-21T14:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing Alert leads me to Labeling Expression error ?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1607641#M95134</link>
      <description>&lt;P&gt;Please fix the indenting&lt;/P&gt;</description>
      <pubDate>Mon, 21 Apr 2025 14:25:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1607641#M95134</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-04-21T14:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing Alert leads me to Labeling Expression error ?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1608095#M95168</link>
      <description>&lt;P&gt;If a record contain a null value in [TRAIL_NO], then you'll get the split error. You have to check whether that attribute is not null before attempting to split it (line 7).&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def FindLabel ( [TRAIL_NO], [ADMIN_ORG], [MANAGING_ORG], [TRAIL_NAME], [NATIONAL_TRAIL_DESIGNATION] ):
    if [ADMIN_ORG].startswith('02'):
        s='.'
        if [ADMIN_ORG].startswith('0201'):
            return [TRAIL_NO] [2:]
        else:
            if [TRAIL_NO]:
                return [TRAIL_NO].split(s,1)[0]
            else:
                return "TRAIL_NO is null"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Apr 2025 14:31:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1608095#M95168</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-04-22T14:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing Alert leads me to Labeling Expression error ?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1608184#M95178</link>
      <description>&lt;P&gt;I fixed it and it worked; however on line 2 which I am not sure about but I can see the Admin_Org has null and I don't know how to include it in the code ?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def FindLabel ( [TRAIL_NO], [ADMIN_ORG], [MANAGING_ORG], [TRAIL_NAME],[NATIONAL_TRAIL_DESIGNATION]):
    if [ADMIN_ORG].startswith('02'):
        s='.'
        if [ADMIN_ORG].startswith('0201'):
            return [TRAIL_NO][2:]
        else:
            if [TRAIL_NO]:
                return [TRAIL_NO]
            else:
                return "TRAIL_NO is null"&lt;/LI-CODE&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;expression&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 2, in FindLabel&lt;BR /&gt;AttributeError: 'NoneType' object has no attribute 'startswith'&lt;/P&gt;&lt;P&gt;And here is the screenshot for the field name here is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PROBERT68_0-1745341645327.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/130754iE3FE34CEA27845AD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PROBERT68_0-1745341645327.png" alt="PROBERT68_0-1745341645327.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Apr 2025 17:07:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1608184#M95178</guid>
      <dc:creator>DEAF_PROBERT_68</dc:creator>
      <dc:date>2025-04-22T17:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing Alert leads me to Labeling Expression error ?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1608218#M95184</link>
      <description>&lt;P&gt;You'll have to do the same thing with any field that a text function (split, startswith, replace, etc). Since most of the conditional lines are testing&amp;nbsp;[ADMIN_ORG], you should put that at the beginning, like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def FindLabel ( [TRAIL_NO], [ADMIN_ORG], [MANAGING_ORG], [TRAIL_NAME],[NATIONAL_TRAIL_DESIGNATION]):
    if [ADMIN_ORG]:
        if [ADMIN_ORG].startswith('02'):
        //&lt;/LI-CODE&gt;&lt;P&gt;You can put that on one line, like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;elif [MANAGING_ORG] and [MANAGING_ORG].startswith('031204'):&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 22 Apr 2025 18:09:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/drawing-alert-leads-me-to-labeling-expression/m-p/1608218#M95184</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-04-22T18:09:47Z</dc:date>
    </item>
  </channel>
</rss>

