<?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 Use arcade dictionary based on one field to populate values for another in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/use-arcade-dictionary-based-on-one-field-to/m-p/1341146#M74379</link>
    <description>&lt;P&gt;I have two fields in my attribute table: Incorporated City Names, and Unincorporated City Names. I am trying to create a dictionary for each columns' values, and replace them with a 3-letter city code, which I would then like to populate another column with.&lt;/P&gt;&lt;P&gt;First, I am curious about whether I can do this with just one dictionary or if I need two, one for each column. I have included one dictionary per column in this example. Here is what I have so far and where I am getting stuck:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//The field I am trying to populate based off of the dictionaries
var citycode = "citycode";
//One of two fields that has the values I would like to use to populate values for the above
var incmuni = "incmuni"
//The other field I would like to use
var uninccom = "uninccom"

//Define the 3-letter city code dictionaries
var incDict = {"ALTA" : "ALT", "BRIGHTON" : "BRT", "BLUFFDALE" : "BLU", 
                "COTTONWOOD HEIGHTS" : "COT","DRAPER" : "DRA", "HERRIMAN" : "HER", 
                "HOLLADAY" : "HOL","MIDVALE" : "MID", "MILLCREEK" : "MCK", 
                "MURRAY" : "MUR","RIVERTON": "RIV", "SALT LAKE CITY" : "SLC",
                "SALT LAKE COUNTY" : "SCO", "SANDY" : "SAN", "SOUTH JORDAN" : "SJC",
                "SOUTH SALT LAKE" : "SSL", "TAYLORSVILLE" : "TAY", 
                "WEST JORDAN" : "WJC", "WEST VALLEY" : "WVC"}

var unincDict ={"COPPERTON" : "COP", "EMIGRATION CANYON" : "EMC",
               "KEARNS" : "KEA", "MAGNA" : "MAG", 
               "UNINCORPORATED" : "SCO", "WHITE CITY" : "WHC"}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is where I have tried various things, but mostly have followed this kind of logic (sorry if my arguments are the wrong way around, I have tried them in various ways but am new to this):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//if there is a value for the incmuni field, create variable, use it to populate the citycode column with its respective 3-letter code equivalent using the incDict dictionary
//else return the 3-letter code equivalent using the uninc dictionary

if (HasKey(unincDict, uninccom)) return;
var citycodeUpdated = unincDict[citycode];
else (HasKey(incDict, incmuni)) return;
var citycodeUpdated = incDict[citycode];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I would then like to return the values to the citycode column like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;return {
    "result": {
        "attributes":
            Dictionary(
                citycode, citycodeUpdated)
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thank you for any help in advance!&lt;/P&gt;</description>
    <pubDate>Tue, 24 Oct 2023 21:11:37 GMT</pubDate>
    <dc:creator>masslc</dc:creator>
    <dc:date>2023-10-24T21:11:37Z</dc:date>
    <item>
      <title>Use arcade dictionary based on one field to populate values for another</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/use-arcade-dictionary-based-on-one-field-to/m-p/1341146#M74379</link>
      <description>&lt;P&gt;I have two fields in my attribute table: Incorporated City Names, and Unincorporated City Names. I am trying to create a dictionary for each columns' values, and replace them with a 3-letter city code, which I would then like to populate another column with.&lt;/P&gt;&lt;P&gt;First, I am curious about whether I can do this with just one dictionary or if I need two, one for each column. I have included one dictionary per column in this example. Here is what I have so far and where I am getting stuck:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//The field I am trying to populate based off of the dictionaries
var citycode = "citycode";
//One of two fields that has the values I would like to use to populate values for the above
var incmuni = "incmuni"
//The other field I would like to use
var uninccom = "uninccom"

//Define the 3-letter city code dictionaries
var incDict = {"ALTA" : "ALT", "BRIGHTON" : "BRT", "BLUFFDALE" : "BLU", 
                "COTTONWOOD HEIGHTS" : "COT","DRAPER" : "DRA", "HERRIMAN" : "HER", 
                "HOLLADAY" : "HOL","MIDVALE" : "MID", "MILLCREEK" : "MCK", 
                "MURRAY" : "MUR","RIVERTON": "RIV", "SALT LAKE CITY" : "SLC",
                "SALT LAKE COUNTY" : "SCO", "SANDY" : "SAN", "SOUTH JORDAN" : "SJC",
                "SOUTH SALT LAKE" : "SSL", "TAYLORSVILLE" : "TAY", 
                "WEST JORDAN" : "WJC", "WEST VALLEY" : "WVC"}

var unincDict ={"COPPERTON" : "COP", "EMIGRATION CANYON" : "EMC",
               "KEARNS" : "KEA", "MAGNA" : "MAG", 
               "UNINCORPORATED" : "SCO", "WHITE CITY" : "WHC"}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is where I have tried various things, but mostly have followed this kind of logic (sorry if my arguments are the wrong way around, I have tried them in various ways but am new to this):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//if there is a value for the incmuni field, create variable, use it to populate the citycode column with its respective 3-letter code equivalent using the incDict dictionary
//else return the 3-letter code equivalent using the uninc dictionary

if (HasKey(unincDict, uninccom)) return;
var citycodeUpdated = unincDict[citycode];
else (HasKey(incDict, incmuni)) return;
var citycodeUpdated = incDict[citycode];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I would then like to return the values to the citycode column like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;return {
    "result": {
        "attributes":
            Dictionary(
                citycode, citycodeUpdated)
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thank you for any help in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2023 21:11:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/use-arcade-dictionary-based-on-one-field-to/m-p/1341146#M74379</guid>
      <dc:creator>masslc</dc:creator>
      <dc:date>2023-10-24T21:11:37Z</dc:date>
    </item>
  </channel>
</rss>

