<?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: Attribute Rule Refinement: Extract Characters from one field, compare coded domain and return domain description in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-refinement-extract-characters-from/m-p/1632398#M97176</link>
    <description>&lt;P&gt;I went at it with ChatGPT again, this time it gave me this expression and it worked.&amp;nbsp; Perhaps I just needed a fresh look at it.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var src=$feature.PARCELNO;
if (IsEmpty(src) || Count(src) &amp;lt; 3) {
  return null;
}
var prefix = Left(src, 3);

var d = Domain($feature, "Municipality");  // note: exact field name
if (d == null || d.type != "codedValue") {
  return null;
}

for (var cv of d.codedValues) {
  if (Left(Text(cv.code), 3) == prefix) {
    return cv.name;
  }
}

return null;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Jul 2025 13:43:44 GMT</pubDate>
    <dc:creator>GrantCountyGISSup</dc:creator>
    <dc:date>2025-07-11T13:43:44Z</dc:date>
    <item>
      <title>Attribute Rule Refinement: Extract Characters from one field, compare coded domain and return domain description</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-refinement-extract-characters-from/m-p/1632394#M97175</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;My goal with this rule is to get it to auto-populate our municipality field with a domain description when a user types in a parcel number.&lt;/P&gt;&lt;P&gt;I have assigned the Municipality_Codes domain to the Municipality field.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GrantCountyGISSup_0-1752240532712.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/136372i9950F714A61D9E8F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GrantCountyGISSup_0-1752240532712.png" alt="GrantCountyGISSup_0-1752240532712.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is what the Municipality_Codes domain looks like:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GrantCountyGISSup_1-1752240679481.png" style="width: 647px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/136374i652B89863F5594E7/image-dimensions/647x186?v=v2" width="647" height="186" role="button" title="GrantCountyGISSup_1-1752240679481.png" alt="GrantCountyGISSup_1-1752240679481.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The first three numbers of the Parcel # coincides with the three numbers assigned to each municipality in the domain.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the the Arcade expression that I was able to come up with using ChatGPT.&amp;nbsp; It still does not work even if I try to use Calculate Field.&amp;nbsp; I feel like the first 12 lines make sense it's when it goes through the looping is where it is not working.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// 1. Validate PARCELNO &amp;amp; extract prefix
var src=$feature.PARCELNO;
if (IsEmpty(src) || Count(src) &amp;lt; 3) {
return null;
}
var prefix = Left(src, 3);

// 2. Get the full coded value domain object
var d = DomainName($feature, "Municipality");
if (d == null || d.type != "codedValue") {
return null;
}

// 3. Loop through codes
for (var cv of d.codedValues) {
var codeStr = Text(cv.code);
if (codeStr == prefix) {
// 4. Return the matching description
return cv.name;
}
}

return null;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jul 2025 13:36:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-refinement-extract-characters-from/m-p/1632394#M97175</guid>
      <dc:creator>GrantCountyGISSup</dc:creator>
      <dc:date>2025-07-11T13:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute Rule Refinement: Extract Characters from one field, compare coded domain and return domain description</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-refinement-extract-characters-from/m-p/1632398#M97176</link>
      <description>&lt;P&gt;I went at it with ChatGPT again, this time it gave me this expression and it worked.&amp;nbsp; Perhaps I just needed a fresh look at it.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var src=$feature.PARCELNO;
if (IsEmpty(src) || Count(src) &amp;lt; 3) {
  return null;
}
var prefix = Left(src, 3);

var d = Domain($feature, "Municipality");  // note: exact field name
if (d == null || d.type != "codedValue") {
  return null;
}

for (var cv of d.codedValues) {
  if (Left(Text(cv.code), 3) == prefix) {
    return cv.name;
  }
}

return null;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jul 2025 13:43:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-refinement-extract-characters-from/m-p/1632398#M97176</guid>
      <dc:creator>GrantCountyGISSup</dc:creator>
      <dc:date>2025-07-11T13:43:44Z</dc:date>
    </item>
  </channel>
</rss>

