<?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 Create domain with python api script in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/create-domain-with-python-api-script/m-p/1178271#M7438</link>
    <description>&lt;P&gt;My apologies that my question comes with no, I have been asked to transfer data to a feature layer by importing a csv using a python script. I have that working fine but the business has now requested ddl's on the form the csv populates, now so far my attempts were creating the domain on ArcGis online, but when I update the csv data the domain gets deleted, I'm not usually developing ArcGis operability and I'm stumped as to how this really works, any assistence or tutorials will be greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Mon, 30 May 2022 08:40:48 GMT</pubDate>
    <dc:creator>BrianShaw</dc:creator>
    <dc:date>2022-05-30T08:40:48Z</dc:date>
    <item>
      <title>Create domain with python api script</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/create-domain-with-python-api-script/m-p/1178271#M7438</link>
      <description>&lt;P&gt;My apologies that my question comes with no, I have been asked to transfer data to a feature layer by importing a csv using a python script. I have that working fine but the business has now requested ddl's on the form the csv populates, now so far my attempts were creating the domain on ArcGis online, but when I update the csv data the domain gets deleted, I'm not usually developing ArcGis operability and I'm stumped as to how this really works, any assistence or tutorials will be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 30 May 2022 08:40:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/create-domain-with-python-api-script/m-p/1178271#M7438</guid>
      <dc:creator>BrianShaw</dc:creator>
      <dc:date>2022-05-30T08:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create domain with python api script</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/create-domain-with-python-api-script/m-p/1187698#M7518</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/208444"&gt;@BrianShaw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Similar process to this post &lt;A href="https://community.esri.com/t5/arcgis-api-for-python-questions/programmatically-attribute-fields-for-hosted-data/m-p/1187685#M7516" target="_blank" rel="noopener"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Manually add your domains. We will use this as a template. Once complete run a script similar to below.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import GIS

agol = GIS("home")

item = agol.content.get("***fs_id***")

## get the layer in the feature service that you are interested in
## if there is only one then the index is 0
lyr = item.layers[0]

print(lyr.properties.fields)&lt;/LI-CODE&gt;&lt;P&gt;This will print the JSON of the fields configuration to screen. Open a Notepad and insert the below, copy and paste the JSON in the placeholder.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "fields" : 
        *** copy and paste JSON here *** 
}&lt;/LI-CODE&gt;&lt;P&gt;Save as a .json file extension. You now have a template that you can edit in the notepad to update. You can add/alter the domains, just stick to the formatting.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now that you have the template you can use the below to update the fields as necessary.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import GIS
import json

agol = GIS("home")

item = agol.content.get("***fs_id***")

## open the JSON file
with open(r"C:\path\to\lyr_fields.json") as json_data:
    data = json.load(json_data)

lyr = item.layers[0]

lyr.manager.update_definition(data)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 09:23:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/create-domain-with-python-api-script/m-p/1187698#M7518</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2022-06-29T09:23:59Z</dc:date>
    </item>
  </channel>
</rss>

