<?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: View Domain Descriptions with notebooks / workforce / api for python in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/view-domain-descriptions-with-notebooks-workforce/m-p/1285649#M8719</link>
    <description>&lt;P&gt;Thanks, I found this in another forum, and it works for viewing the domains in notebooks. I'm looking to push the domain description value as text into a workforce field (description). Like how the attributes function works in a for loop below. But I just get the coded value back and can't find a way to get the domain description.&amp;nbsp;&lt;/P&gt;&lt;P&gt;feature.attributes['WV_Operation'] outputs a 0 or 1 and not 'Yes' or 'No'&lt;/P&gt;&lt;P&gt;I'm pretty new to this so perhaps I'm just missing how to do this?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;service = gis.content.get('some itemid').layers[0]
assignments = []
for feature in service:
          
    assignments.append(
        workforce.Assignment(
            project,
            geometry=feature.geometry,
            location="Hydrant #" + feature.attributes['HydNum'] + " on " + feature.attributes["LocDesc"],
            description=feature.attributes["WV_Operation"],
            priority=1,
            work_order_id=feature.attributes["GlobalID"],
            assignment_type="Auxiliary Valve Issues",
            status="assigned",
            worker=Robyn
        )
    )
project.assignments.batch_add(assignments)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 May 2023 13:54:23 GMT</pubDate>
    <dc:creator>RobynSnookCCB</dc:creator>
    <dc:date>2023-05-04T13:54:23Z</dc:date>
    <item>
      <title>View Domain Descriptions with notebooks / workforce / api for python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/view-domain-descriptions-with-notebooks-workforce/m-p/1285584#M8717</link>
      <description>&lt;P&gt;I am attempting to automat adding assignments to our workforce projects. I've got that done but where using field maps with a separate feature layer and I want to push that data into the description field of the workforce layer. However, some fields have coded domains. I am new to api for python and am unable to find a way to view domain descriptions vs the coded value. Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 11:05:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/view-domain-descriptions-with-notebooks-workforce/m-p/1285584#M8717</guid>
      <dc:creator>RobynSnookCCB</dc:creator>
      <dc:date>2023-05-04T11:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: View Domain Descriptions with notebooks / workforce / api for python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/view-domain-descriptions-with-notebooks-workforce/m-p/1285642#M8718</link>
      <description>&lt;P&gt;With a feature service, you can use the &lt;STRONG&gt;properties&lt;/STRONG&gt; to pull out domains for each field.&lt;/P&gt;&lt;P&gt;Once you have your service, you can use this one-liner to cobble together a dict of the layer's domains:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;service = gis.content.get('some itemid').layers[0]

domains = {i['name']:{str(j['code']):j['name'] for (j) in i['domain']['codedValues']} for (i) in service.properties["fields"] if 'domain' in i and i['domain'] is not None}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1683207701427.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69861i87BEA7118A5ADEF4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1683207701427.png" alt="jcarlson_0-1683207701427.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 13:41:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/view-domain-descriptions-with-notebooks-workforce/m-p/1285642#M8718</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-05-04T13:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: View Domain Descriptions with notebooks / workforce / api for python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/view-domain-descriptions-with-notebooks-workforce/m-p/1285649#M8719</link>
      <description>&lt;P&gt;Thanks, I found this in another forum, and it works for viewing the domains in notebooks. I'm looking to push the domain description value as text into a workforce field (description). Like how the attributes function works in a for loop below. But I just get the coded value back and can't find a way to get the domain description.&amp;nbsp;&lt;/P&gt;&lt;P&gt;feature.attributes['WV_Operation'] outputs a 0 or 1 and not 'Yes' or 'No'&lt;/P&gt;&lt;P&gt;I'm pretty new to this so perhaps I'm just missing how to do this?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;service = gis.content.get('some itemid').layers[0]
assignments = []
for feature in service:
          
    assignments.append(
        workforce.Assignment(
            project,
            geometry=feature.geometry,
            location="Hydrant #" + feature.attributes['HydNum'] + " on " + feature.attributes["LocDesc"],
            description=feature.attributes["WV_Operation"],
            priority=1,
            work_order_id=feature.attributes["GlobalID"],
            assignment_type="Auxiliary Valve Issues",
            status="assigned",
            worker=Robyn
        )
    )
project.assignments.batch_add(assignments)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 13:54:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/view-domain-descriptions-with-notebooks-workforce/m-p/1285649#M8719</guid>
      <dc:creator>RobynSnookCCB</dc:creator>
      <dc:date>2023-05-04T13:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: View Domain Descriptions with notebooks / workforce / api for python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/view-domain-descriptions-with-notebooks-workforce/m-p/1285658#M8720</link>
      <description>&lt;P&gt;Once you have a domains dict, you can use the field name and attribute value to swap in the appropriate domain descriptions.&lt;/P&gt;&lt;PRE&gt;domains['fieldname'][feature['attributes']['fieldname']&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1683208905240.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69863iE685DB0EFDEF37AA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1683208905240.png" alt="jcarlson_0-1683208905240.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Or if you use a dataframe, you can replace all the domains with their descriptions in one go:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_1-1683209297861.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69865i2B2D8ACE8357AA70/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_1-1683209297861.png" alt="jcarlson_1-1683209297861.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 14:08:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/view-domain-descriptions-with-notebooks-workforce/m-p/1285658#M8720</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-05-04T14:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: View Domain Descriptions with notebooks / workforce / api for python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/view-domain-descriptions-with-notebooks-workforce/m-p/1285662#M8721</link>
      <description>&lt;P&gt;Great thank you, it has worked! For anyone else I did need to tweak the exact code to:&amp;nbsp;&lt;/P&gt;&lt;P&gt;domains['Ownership'][feature.attributes['Ownership']]&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 14:19:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/view-domain-descriptions-with-notebooks-workforce/m-p/1285662#M8721</guid>
      <dc:creator>RobynSnookCCB</dc:creator>
      <dc:date>2023-05-04T14:19:49Z</dc:date>
    </item>
  </channel>
</rss>

