<?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: arcpy layout.export - hosted feature layers not showing up in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-layout-export-hosted-feature-layers-not/m-p/1663359#M99951</link>
    <description>&lt;P&gt;I've run into similar issues before with Layouts not refreshing properly using bookmarks/mapseries elements. Something that has worked for me in the past is to just force a CIM reload:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;...
lyt = aprx.listLayouts("Weekly")[0]
mf = lyt.listElements("MAPFRAME_ELEMENT", "LAYERS Map Frame")[0]
bookmark = m.listBookmarks(project_area)[0]
mf.zoomToBookmark(bookmark)

# Force a reload of the layout by overwriting the CIM
lyt.setDefinition(lyt.getDefinition('V3'))
... # You can remove the time.sleep here now&lt;/LI-CODE&gt;&lt;P&gt;See &lt;A href="https://community.esri.com/t5/arcgis-pro-ideas/layout-refresh-method-for-arcpy-mp/idi-p/1508038" target="_self"&gt;here&lt;/A&gt; for a discussion with the arcpy.mp team on this&lt;/P&gt;</description>
    <pubDate>Tue, 04 Nov 2025 20:16:55 GMT</pubDate>
    <dc:creator>HaydenWelch</dc:creator>
    <dc:date>2025-11-04T20:16:55Z</dc:date>
    <item>
      <title>arcpy layout.export - hosted feature layers not showing up</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-layout-export-hosted-feature-layers-not/m-p/1663346#M99949</link>
      <description>&lt;P&gt;The goal is to publish a geoprocessing tool that:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Opens predefined Pro project&lt;/LI&gt;&lt;LI&gt;Sets definition queries on hosted feature service layers (date ranges)&lt;/LI&gt;&lt;LI&gt;Turns ON the hosted feat. service layers&lt;/LI&gt;&lt;LI&gt;Zooms to a predefined bookmark&lt;/LI&gt;&lt;LI&gt;Exports to JPG&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Pretty simple, right? Not so much. No matter what we do, the hosted feature service layer(s) aren't drawing. Sometimes they do draw, sometimes they don't; most often not.&lt;/P&gt;&lt;P&gt;Can anyone spot an issue?&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os, time
from datetime import datetime

start_date = arcpy.GetParameterAsText(0) #1761486465000
end_date = arcpy.GetParameterAsText(1) #1762004877000
report_type = arcpy.GetParameterAsText(2) #"Cultural Resources"
project_area = arcpy.GetParameterAsText(3) #"Project 1"
output_map_filename = arcpy.GetParameterAsText(4) #"aTest"
output_map_file = arcpy.GetParameterAsText(5)

lyr_wildcard = "CR*" if report_type == "Cultural Resources" else "NR*"

start_date_str = datetime.fromtimestamp(start_date / 1000).strftime("%m/%d/%Y") if str(start_date).isdigit() else start_date
end_date_str = datetime.fromtimestamp(end_date / 1000).strftime("%m/%d/%Y") if str(end_date).isdigit() else end_date

arcpy.env.overwriteOutput = True

def find_dt_field(lyr_datasrc):
    flds_to_ignore = ["created_date","last_edited_date"]
    for fld in arcpy.ListFields(lyr_datasrc,"*_date","DateOnly"):
        if not fld.name in flds_to_ignore:
            return fld.name
            break

aprx = arcpy.mp.ArcGISProject(r"\\nafiles-our.domain.com\Weekly Report Map GP Tool dev.aprx")

m = aprx.listMaps("weekrep")[0]

lyrs = [l for l in m.listLayers(lyr_wildcard) if not l.isGroupLayer]
for lyr in lyrs:
    if lyr.supports("DEFINITIONQUERY"):
        dt_fld = find_dt_field(lyr.dataSource)
        sql_query = dt_fld + " &amp;gt;= date '" + start_date_str + "' AND " + dt_fld + " &amp;lt;= date '" + end_date_str + "'"
        lyr.definitionQuery = sql_query
        lyr.visible = True

lyt = aprx.listLayouts("Weekly")[0]
mf = lyt.listElements("MAPFRAME_ELEMENT", "LAYERS Map Frame")[0]
bookmark = m.listBookmarks(project_area)[0]
mf.zoomToBookmark(bookmark)

time.sleep(15) #let all the complex labels draw
output_file = os.path.join(arcpy.env.scratchFolder,output_map_filename)

pdf_export_format = arcpy.mp.CreateExportFormat("PDF",output_file)
pdf_export_format.georefInfo = False
pdf_export_format.resolution = 300
pdf_export_format.imageCompressionQuality = 100
arcpy.SetParameterAsText(5, lyt.export(pdf_export_format))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Nov 2025 19:45:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-layout-export-hosted-feature-layers-not/m-p/1663346#M99949</guid>
      <dc:creator>danbecker</dc:creator>
      <dc:date>2025-11-04T19:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy layout.export - hosted feature layers not showing up</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-layout-export-hosted-feature-layers-not/m-p/1663350#M99950</link>
      <description>&lt;P&gt;Can't test at the moment, but you might be able to open the project in Pro, then run the script.&amp;nbsp; Then you could look at the definition queries applied to the layers and see if they are valid?&lt;/P&gt;&lt;P&gt;Might give an idea as to the issue.&amp;nbsp; Sometimes it's just a small syntax issue and can sometimes take a bit to figure out the right coding to string a where clause together in the proper format.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;Edit to add:&lt;/P&gt;&lt;P&gt;It could also depend on what your data source is.&amp;nbsp; If I set up a similar definition query in Pro on data from SQL Server through .sde connection file:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;dt_fld &amp;gt;= '2025-01-02 00:00:00' And dt_fld &amp;lt;= '2025-12-02 00:00:00'&lt;/LI-CODE&gt;&lt;P&gt;But in the same project, if I connect to a FGDB feature class, the same query becomes:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;dt_fld &amp;gt;= timestamp '2025-01-02 00:00:00' And dt_fld &amp;lt;= timestamp '2025-12-30 00:00:00'&lt;/LI-CODE&gt;&lt;P&gt;Neither of which have the 'date' in them.&amp;nbsp; I remember seeing that before, so 'some' data source(s) must require it that way.&amp;nbsp; Another reason to check the def queries in Pro itself after the script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Nov 2025 21:23:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-layout-export-hosted-feature-layers-not/m-p/1663350#M99950</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2025-11-04T21:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy layout.export - hosted feature layers not showing up</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-layout-export-hosted-feature-layers-not/m-p/1663359#M99951</link>
      <description>&lt;P&gt;I've run into similar issues before with Layouts not refreshing properly using bookmarks/mapseries elements. Something that has worked for me in the past is to just force a CIM reload:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;...
lyt = aprx.listLayouts("Weekly")[0]
mf = lyt.listElements("MAPFRAME_ELEMENT", "LAYERS Map Frame")[0]
bookmark = m.listBookmarks(project_area)[0]
mf.zoomToBookmark(bookmark)

# Force a reload of the layout by overwriting the CIM
lyt.setDefinition(lyt.getDefinition('V3'))
... # You can remove the time.sleep here now&lt;/LI-CODE&gt;&lt;P&gt;See &lt;A href="https://community.esri.com/t5/arcgis-pro-ideas/layout-refresh-method-for-arcpy-mp/idi-p/1508038" target="_self"&gt;here&lt;/A&gt; for a discussion with the arcpy.mp team on this&lt;/P&gt;</description>
      <pubDate>Tue, 04 Nov 2025 20:16:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-layout-export-hosted-feature-layers-not/m-p/1663359#M99951</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-11-04T20:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy layout.export - hosted feature layers not showing up</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-layout-export-hosted-feature-layers-not/m-p/1663397#M99957</link>
      <description>&lt;P&gt;I have called aprx.save() and looked at the applied def queries and they're all Ok.&lt;/P&gt;&lt;P&gt;I also tried the suggested layout 'refresh' and still have the problem. Sometimes, the HFL shows up in the legend, because it's visible, but none of the labels or features draw.&lt;/P&gt;&lt;P&gt;We have a similar GP tool we published, but that Pro project uses solely enterprise gdb data from our postgres instance..zero problems.&lt;/P&gt;&lt;P&gt;This problematic project has Fgdb's referenced, HFLs and enterprise gdb sources..all are referenced.when published.&lt;/P&gt;&lt;P&gt;But, we're barley at the publishing stage. It too doesn't draw the HFL points. Neither does the script run from Toolbox in Pro.&lt;/P&gt;&lt;P&gt;Only sometimes it works, all the same input parameters.&lt;/P&gt;&lt;P&gt;Bizzare&lt;/P&gt;</description>
      <pubDate>Wed, 05 Nov 2025 13:31:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-layout-export-hosted-feature-layers-not/m-p/1663397#M99957</guid>
      <dc:creator>danbecker</dc:creator>
      <dc:date>2025-11-05T13:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy layout.export - hosted feature layers not showing up</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-layout-export-hosted-feature-layers-not/m-p/1663398#M99958</link>
      <description>&lt;P&gt;It's worth noting..all the problematic HFLs have very complex mapPlex labeling properties set. Stacking, lead lines, weights, ect.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Nov 2025 21:42:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-layout-export-hosted-feature-layers-not/m-p/1663398#M99958</guid>
      <dc:creator>danbecker</dc:creator>
      <dc:date>2025-11-04T21:42:20Z</dc:date>
    </item>
  </channel>
</rss>

