<?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: Share/Overwrite Web Layer with Arcade expression - Python in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/share-overwrite-web-layer-with-arcade-expression/m-p/727774#M27720</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am seeing something similar.&amp;nbsp; Do you ever resovle?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 04 Apr 2020 16:42:34 GMT</pubDate>
    <dc:creator>JonathanPollack1</dc:creator>
    <dc:date>2020-04-04T16:42:34Z</dc:date>
    <item>
      <title>Share/Overwrite Web Layer with Arcade expression - Python</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/share-overwrite-web-layer-with-arcade-expression/m-p/727773#M27719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;I have a feature class that I have symbolized using Arcade combining two fields to create different symbols; something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var code = $feature.FIELD1&lt;BR /&gt;var&amp;nbsp;state = $feature.FIELD2&lt;/P&gt;&lt;P&gt;if (code == '0' &amp;amp;&amp;amp;&amp;nbsp;state == 'Unknown' || &lt;BR /&gt;code == '1' &amp;amp;&amp;amp;&amp;nbsp;state == 'State 1' || &lt;BR /&gt;code == '1' &amp;amp;&amp;amp;&amp;nbsp;state == 'State 2') {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return 'Symbol 1';&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;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;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;else {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return 'Symbol 3';&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works fine, I have done it for 20 categories. When I publish this layer as a Web Layer using "Sharing\Share as a Web Layer" in ArcGIS PRO the service is&amp;nbsp;published&amp;nbsp;keeping the symbology (the ARCADE&amp;nbsp;expression&amp;nbsp;is kept and transferred into the Portal). The service definition file (.sd) is also created without any problem and published into the Portal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I want to do the same using a python script to automate the process the&amp;nbsp;python shell gives me some warnings:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WARNING 002893: Analyzer warnings were encountered ([{"code":"24041","message":"Layer does not have a feature template set","object":"MY LAYER"}].&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It publishes the web service, but I only get an unique point symbol (the Arcade symbology get lost in the process). If I define the symbology, in Portal using Arcade, when I try to overwrite the web services, also using a python script the symbology change to an unique symbol (as I was expecting,&amp;nbsp;because&amp;nbsp;it seems the service definition file is not recognizing the Arcade expression when using python).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code that I am using is something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import os&lt;BR /&gt;from arcgis.gis import GIS&lt;/P&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;# Sign in to portal&lt;BR /&gt;arcpy.SignInToPortal('My portal', 'MyUserName', 'MyPassword')&lt;/P&gt;&lt;P&gt;# Set output file names&lt;BR /&gt;outdir = "My folder"&lt;BR /&gt;service = "Service_name"&lt;BR /&gt;sddraft_filename = service + ".sddraft"&lt;BR /&gt;sddraft_output_filename = os.path.join(outdir, sddraft_filename)&lt;BR /&gt;print (sddraft_output_filename)&lt;/P&gt;&lt;P&gt;# Reference map to publish&lt;BR /&gt;aprx = arcpy.mp.ArcGISProject(r"path with my project.aprx")&lt;BR /&gt;print (aprx)&lt;BR /&gt;for maps in aprx.listMaps("My map"):&lt;BR /&gt; print (maps.name," map read from my project")&lt;BR /&gt; for lyr in maps.listLayers("MY LAYER"):&lt;BR /&gt; print (lyr.name," layer read from my project")&lt;/P&gt;&lt;P&gt;# Create FeatureSharingDraft and set service properties &lt;BR /&gt; print ("Creating Sharing Draft...")&lt;BR /&gt; sharing_draft = maps.getWebLayerSharingDraft("HOSTING_SERVER", "FEATURE", service)&lt;BR /&gt; sharing_draft.summary = "My summary"&lt;BR /&gt; sharing_draft.tags = "My tags"&lt;BR /&gt; sharing_draft.description = "My description"&lt;BR /&gt; sharing_draft.credits = "My credits"&lt;BR /&gt; sharing_draft.useLimitations = "My use limitations"&lt;BR /&gt; sharing_draft.portalFolder = "The Portal folder name"&lt;/P&gt;&lt;P&gt;# Create Service Definition Draft file&lt;BR /&gt; print ("Exporting Service Definition Draft File...")&lt;BR /&gt; sharing_draft.exportToSDDraft(sddraft_output_filename)&lt;/P&gt;&lt;P&gt;# Stage Service&lt;BR /&gt; print ("Staging service...")&lt;BR /&gt; sd_filename = service + ".sd"&lt;BR /&gt; sd_output_filename = os.path.join(outdir, sd_filename)&lt;BR /&gt; print (sd_output_filename)&lt;/P&gt;&lt;P&gt;print("Creating ",sd_filename),&lt;BR /&gt; arcpy.StageService_server(sddraft_output_filename, sd_output_filename)&lt;BR /&gt; print (arcpy.GetMessages())&lt;/P&gt;&lt;P&gt;# Publish to server&lt;BR /&gt; print("Uploading Service Definition...")&lt;BR /&gt; # Set local variables&lt;BR /&gt; inServer = "HOSTING_SERVER"&lt;BR /&gt; &lt;BR /&gt; # Execute UploadServiceDefinition&lt;BR /&gt; arcpy.UploadServiceDefinition_server(in_sd_file=sd_output_filename, in_server=inServer, in_service_name=service, in_cluster="default", in_folder_type="EXISTING", in_folder="The Portal folder name", in_startupType="STARTED", in_override="OVERRIDE_DEFINITION", in_my_contents="SHARE_ONLINE", in_public="PRIVATE", in_organization="NO_SHARE_ORGANIZATION", in_groups="Groups that I want to share with")&lt;/P&gt;&lt;P&gt;print("Successfully Uploaded service.")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a limitation for the function to transfer the Arcade expression when using arcpy?. Or Am I missing something in the process?. Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andres&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Feb 2020 03:24:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/share-overwrite-web-layer-with-arcade-expression/m-p/727773#M27719</guid>
      <dc:creator>AndresEcheverri</dc:creator>
      <dc:date>2020-02-06T03:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Share/Overwrite Web Layer with Arcade expression - Python</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/share-overwrite-web-layer-with-arcade-expression/m-p/727774#M27720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am seeing something similar.&amp;nbsp; Do you ever resovle?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Apr 2020 16:42:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/share-overwrite-web-layer-with-arcade-expression/m-p/727774#M27720</guid>
      <dc:creator>JonathanPollack1</dc:creator>
      <dc:date>2020-04-04T16:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: Share/Overwrite Web Layer with Arcade expression - Python</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/share-overwrite-web-layer-with-arcade-expression/m-p/727775#M27721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jonathan&lt;/P&gt;&lt;P&gt;I solved the problem calculating a new field with the categories I wanted to use, but using code blocks within the Python Script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2020 23:25:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/share-overwrite-web-layer-with-arcade-expression/m-p/727775#M27721</guid>
      <dc:creator>AndresEcheverri</dc:creator>
      <dc:date>2020-04-07T23:25:16Z</dc:date>
    </item>
  </channel>
</rss>

