<?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 Updating Feature layers with Standalone Tables in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-feature-layers-with-standalone-tables/m-p/843676#M3613</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am currently tasked with developing&amp;nbsp;an automated workflow from Arc Pro to a Dashboard hosted on AGOL. In Pro, I have a symbolized map layer with about eight standalone tables. I add the map to the dashboard and use the standalone tables to create serial charts and indicators.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue I keep running into is that when I attempt to update my feature layer on AGOL, the layer and/or standalone tables will either duplicate or will not update entirely. I am using the cookie-cutter code provided by ESRI for updating web content, but I am not sure what I am missing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;sys&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;os&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;tempfile&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;json&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;logging&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;arcpy&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;fnmatch&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;shutil&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;subprocess&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;arcgis
&lt;SPAN style="color: #cc7832;"&gt;from &lt;/SPAN&gt;arcgis.gis &lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;GIS
&lt;SPAN style="color: #cc7832;"&gt;from &lt;/SPAN&gt;arcgis.mapping &lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;WebMap

&lt;SPAN style="color: #808080;"&gt;### Start setting variables
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;# Set the path to the project
&lt;/SPAN&gt;prjPath = &lt;SPAN style="color: #6a8759;"&gt;r"pathToProject.aprx"
&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;# Update following variables to match
&lt;/SPAN&gt;sd_fs_name = &lt;SPAN style="color: #6a8759;"&gt;r'SERVICE DEFINITION NAME'
&lt;/SPAN&gt;Map = &lt;SPAN style="color: #6a8759;"&gt;r'WEB MAP NAME'
&lt;/SPAN&gt;portal = &lt;SPAN style="color: #6a8759;"&gt;r'http://www.arcgis.com'
&lt;/SPAN&gt;user = &lt;SPAN style="color: #6a8759;"&gt;r'USER'
&lt;/SPAN&gt;password = &lt;SPAN style="color: #6a8759;"&gt;r'PASSWORD'
&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;# Set sharing options
&lt;/SPAN&gt;shrOrg = &lt;SPAN style="color: #cc7832;"&gt;False
&lt;/SPAN&gt;shrEveryone = &lt;SPAN style="color: #cc7832;"&gt;False
&lt;/SPAN&gt;shrGroups = &lt;SPAN style="color: #6a8759;"&gt;""
&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;### End setting variables
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;# Local paths to create temporary content
&lt;/SPAN&gt;relPath = os.path.dirname(prjPath)
sddraft = os.path.join(relPath&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"WebUpdate.sddraft"&lt;/SPAN&gt;)
sd = os.path.join(relPath&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"WebUpdate.sd"&lt;/SPAN&gt;)

&lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;# Create a new SDDraft and stage to SD
&lt;/SPAN&gt;&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Creating SD file'&lt;/SPAN&gt;)
arcpy.env.overwriteOutput = &lt;SPAN style="color: #cc7832;"&gt;True
&lt;/SPAN&gt;prj = arcpy.mp.ArcGISProject(prjPath)
mp = prj.listMaps()[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;]
arcpy.mp.CreateWebLayerSDDraft(mp&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;sddraft&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;sd_fs_name&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'MY_HOSTED_SERVICES'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;                               &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'FEATURE_ACCESS'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;''&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,True, True&lt;/SPAN&gt;)
arcpy.StageService_server(sddraft&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;sd)

&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Connecting to {}'&lt;/SPAN&gt;.format(portal))
gis = GIS(portal&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;user&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;password)

&lt;SPAN style="color: #808080;"&gt;# Find the SD, update it, publish with overwrite and set sharing and metadata
&lt;/SPAN&gt;&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Searching for original SD on portal...'&lt;/SPAN&gt;)
sditem = gis.content.search(&lt;SPAN style="color: #6a8759;"&gt;'{} AND owner:{}'&lt;/SPAN&gt;.format(sd_fs_name&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;user)&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;item_type &lt;/SPAN&gt;= &lt;SPAN style="color: #6a8759;"&gt;'Service Definition'&lt;/SPAN&gt;)[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;]
&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Found SD:{}, ID:{}n Uploading and overwriting...'&lt;/SPAN&gt;.format(sditem.title&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;sditem.id))
sditem.update(&lt;SPAN style="color: #aa4926;"&gt;data&lt;/SPAN&gt;=sd)
&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Overwriting existing feature service...'&lt;/SPAN&gt;)
fs = sditem.publish(&lt;SPAN style="color: #aa4926;"&gt;overwrite&lt;/SPAN&gt;=&lt;SPAN style="color: #cc7832;"&gt;True&lt;/SPAN&gt;)

&lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;shrOrg &lt;SPAN style="color: #cc7832;"&gt;or &lt;/SPAN&gt;shrEveryone &lt;SPAN style="color: #cc7832;"&gt;or &lt;/SPAN&gt;shrGroups:
    &lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Setting sharing options...'&lt;/SPAN&gt;)
    fs.share(&lt;SPAN style="color: #aa4926;"&gt;org&lt;/SPAN&gt;=shrOrg&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;everyone&lt;/SPAN&gt;=shrEveryone&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;groups&lt;/SPAN&gt;=shrGroups)

&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Finishing updating: {} - ID: {}'&lt;/SPAN&gt;.format(fs.title&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;fs.id))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 10:20:08 GMT</pubDate>
    <dc:creator>JackBaldwin</dc:creator>
    <dc:date>2021-12-12T10:20:08Z</dc:date>
    <item>
      <title>Updating Feature layers with Standalone Tables</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-feature-layers-with-standalone-tables/m-p/843676#M3613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am currently tasked with developing&amp;nbsp;an automated workflow from Arc Pro to a Dashboard hosted on AGOL. In Pro, I have a symbolized map layer with about eight standalone tables. I add the map to the dashboard and use the standalone tables to create serial charts and indicators.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue I keep running into is that when I attempt to update my feature layer on AGOL, the layer and/or standalone tables will either duplicate or will not update entirely. I am using the cookie-cutter code provided by ESRI for updating web content, but I am not sure what I am missing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;sys&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;os&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;tempfile&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;json&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;logging&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;arcpy&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;fnmatch&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;shutil&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;subprocess&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;arcgis
&lt;SPAN style="color: #cc7832;"&gt;from &lt;/SPAN&gt;arcgis.gis &lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;GIS
&lt;SPAN style="color: #cc7832;"&gt;from &lt;/SPAN&gt;arcgis.mapping &lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;WebMap

&lt;SPAN style="color: #808080;"&gt;### Start setting variables
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;# Set the path to the project
&lt;/SPAN&gt;prjPath = &lt;SPAN style="color: #6a8759;"&gt;r"pathToProject.aprx"
&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;# Update following variables to match
&lt;/SPAN&gt;sd_fs_name = &lt;SPAN style="color: #6a8759;"&gt;r'SERVICE DEFINITION NAME'
&lt;/SPAN&gt;Map = &lt;SPAN style="color: #6a8759;"&gt;r'WEB MAP NAME'
&lt;/SPAN&gt;portal = &lt;SPAN style="color: #6a8759;"&gt;r'http://www.arcgis.com'
&lt;/SPAN&gt;user = &lt;SPAN style="color: #6a8759;"&gt;r'USER'
&lt;/SPAN&gt;password = &lt;SPAN style="color: #6a8759;"&gt;r'PASSWORD'
&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;# Set sharing options
&lt;/SPAN&gt;shrOrg = &lt;SPAN style="color: #cc7832;"&gt;False
&lt;/SPAN&gt;shrEveryone = &lt;SPAN style="color: #cc7832;"&gt;False
&lt;/SPAN&gt;shrGroups = &lt;SPAN style="color: #6a8759;"&gt;""
&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;### End setting variables
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;# Local paths to create temporary content
&lt;/SPAN&gt;relPath = os.path.dirname(prjPath)
sddraft = os.path.join(relPath&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"WebUpdate.sddraft"&lt;/SPAN&gt;)
sd = os.path.join(relPath&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;"WebUpdate.sd"&lt;/SPAN&gt;)

&lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;# Create a new SDDraft and stage to SD
&lt;/SPAN&gt;&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Creating SD file'&lt;/SPAN&gt;)
arcpy.env.overwriteOutput = &lt;SPAN style="color: #cc7832;"&gt;True
&lt;/SPAN&gt;prj = arcpy.mp.ArcGISProject(prjPath)
mp = prj.listMaps()[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;]
arcpy.mp.CreateWebLayerSDDraft(mp&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;sddraft&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;sd_fs_name&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'MY_HOSTED_SERVICES'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;                               &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'FEATURE_ACCESS'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;''&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,True, True&lt;/SPAN&gt;)
arcpy.StageService_server(sddraft&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;sd)

&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Connecting to {}'&lt;/SPAN&gt;.format(portal))
gis = GIS(portal&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;user&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;password)

&lt;SPAN style="color: #808080;"&gt;# Find the SD, update it, publish with overwrite and set sharing and metadata
&lt;/SPAN&gt;&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Searching for original SD on portal...'&lt;/SPAN&gt;)
sditem = gis.content.search(&lt;SPAN style="color: #6a8759;"&gt;'{} AND owner:{}'&lt;/SPAN&gt;.format(sd_fs_name&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;user)&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;item_type &lt;/SPAN&gt;= &lt;SPAN style="color: #6a8759;"&gt;'Service Definition'&lt;/SPAN&gt;)[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;]
&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Found SD:{}, ID:{}n Uploading and overwriting...'&lt;/SPAN&gt;.format(sditem.title&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;sditem.id))
sditem.update(&lt;SPAN style="color: #aa4926;"&gt;data&lt;/SPAN&gt;=sd)
&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Overwriting existing feature service...'&lt;/SPAN&gt;)
fs = sditem.publish(&lt;SPAN style="color: #aa4926;"&gt;overwrite&lt;/SPAN&gt;=&lt;SPAN style="color: #cc7832;"&gt;True&lt;/SPAN&gt;)

&lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;shrOrg &lt;SPAN style="color: #cc7832;"&gt;or &lt;/SPAN&gt;shrEveryone &lt;SPAN style="color: #cc7832;"&gt;or &lt;/SPAN&gt;shrGroups:
    &lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Setting sharing options...'&lt;/SPAN&gt;)
    fs.share(&lt;SPAN style="color: #aa4926;"&gt;org&lt;/SPAN&gt;=shrOrg&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;everyone&lt;/SPAN&gt;=shrEveryone&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;groups&lt;/SPAN&gt;=shrGroups)

&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;'Finishing updating: {} - ID: {}'&lt;/SPAN&gt;.format(fs.title&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;fs.id))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:20:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-feature-layers-with-standalone-tables/m-p/843676#M3613</guid>
      <dc:creator>JackBaldwin</dc:creator>
      <dc:date>2021-12-12T10:20:08Z</dc:date>
    </item>
  </channel>
</rss>

