<?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: Create a List of Layer from Map running into issues where instance has no attributes in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1241594#M63476</link>
    <description>&lt;P&gt;Hello&lt;BR /&gt;I have this code which is working with single item id. But I need to run this on all webmaps on my content or org. I am using notebook on AGOL&lt;BR /&gt;any idea how can I do this?&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from arcgis.gis import GIS
from arcgis.mapping import WebMap
gis = GIS('home')# if running this from Notebook for ArcGIS in AGOL/Enterprise, replace this line with gis = GIS('home')
wmItemId = "myid" #put the id of the webmap in here
wmItem = gis.content.get(wmItemId)
wm = WebMap(wmItem)
for lyr in wm.layers:
    print(lyr.title)
    print(lyr.url)&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 15 Dec 2022 16:44:47 GMT</pubDate>
    <dc:creator>anonymous55</dc:creator>
    <dc:date>2022-12-15T16:44:47Z</dc:date>
    <item>
      <title>Create a List of Layer from Map running into issues where instance has no attributes</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1161830#M53730</link>
      <description>&lt;P&gt;I grabbed code from JoshuaSharp-Heward here&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-online-questions/simple-way-to-export-a-layer-list-for-a-web-map-to/td-p/608298" target="_blank" rel="noopener"&gt;Simple way to export a Layer List for a Web Map to... - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and tweaked it a little to output the layer url with the layer name. Unfortunately I keep running into an issue where one of the items has no attribute and it causes the program to fail. I am trying to write in an exception but don't know how. any help would be appreciated. The exact error is "layer" instance has no attribute 'url'&lt;/P&gt;&lt;P&gt;from arcgis.gis import GIS&lt;BR /&gt;from arcgis.mapping import WebMap&lt;BR /&gt;gis = GIS('pro')# if running this from Notebook for ArcGIS in AGOL/Enterprise, replace this line with gis = GIS('home')&lt;BR /&gt;wmItemId = "" #put the id of the webmap in here&lt;BR /&gt;wmItem = gis.content.get(wmItemId)&lt;BR /&gt;wm = WebMap(wmItem)&lt;BR /&gt;print('\033[1m' +"MapName" )&lt;BR /&gt;for lyr in wm.layers:&lt;BR /&gt;print('\033[0m' + lyr.title + "\n" + lyr.url)&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 20:29:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1161830#M53730</guid>
      <dc:creator>Kayden75</dc:creator>
      <dc:date>2022-04-06T20:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create a List of Layer from Map running into issues where instance has no attributes</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1161939#M53745</link>
      <description>&lt;P&gt;You could do a full-blown try/except, but you really just want to include the URL if it exists. Including a succinct little ternary operator to look for the 'url' key in the dict is very simple:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;[f"{lyr['title']} | {lyr['url'] if 'url' in lyr else 'No URL'}" for lyr in wm.layers]&lt;/LI-CODE&gt;&lt;P&gt;Returns&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;['Records | &lt;A&gt;https://maps.co.kendall.il.us/server/rest/services/Hosted/Change_Record_View/FeatureServer/0&lt;/A&gt;',&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; 'Parcels | &lt;A&gt;https://maps.co.kendall.il.us/server/rest/services/Hosted/Change_Record_View/FeatureServer/1&lt;/A&gt;']&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I don't actually have a no-URL layer to test this on, but I assume it would apply to a sketch layer or something?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 03:04:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1161939#M53745</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-04-07T03:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create a List of Layer from Map running into issues where instance has no attributes</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1162032#M53758</link>
      <description>&lt;P&gt;Awesome this works great. Thank You! Quick question, how do I add a /n to this? It isn't taking. Do I need to add a print in front of&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[f"{lyr['title']} | {lyr['url'] if 'url' in lyr else 'No URL'}" for lyr in wm.layers]&lt;/PRE&gt;&lt;P&gt;?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 13:11:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1162032#M53758</guid>
      <dc:creator>Kayden75</dc:creator>
      <dc:date>2022-04-07T13:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create a List of Layer from Map running into issues where instance has no attributes</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1162043#M53762</link>
      <description>&lt;P&gt;Unfortunately after testing it, it only works when I do one map at a time.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 13:11:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1162043#M53762</guid>
      <dc:creator>Kayden75</dc:creator>
      <dc:date>2022-04-07T13:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create a List of Layer from Map running into issues where instance has no attributes</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1162057#M53763</link>
      <description>&lt;P&gt;I got it to work by adding&amp;nbsp;&lt;/P&gt;&lt;P&gt;try:&lt;BR /&gt;print('\033[0m' + lyr.title + "\n" + lyr.url)&lt;BR /&gt;except:&lt;BR /&gt;print("No Url")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 13:38:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1162057#M53763</guid>
      <dc:creator>Kayden75</dc:creator>
      <dc:date>2022-04-07T13:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create a List of Layer from Map running into issues where instance has no attributes</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1162089#M53769</link>
      <description>&lt;P&gt;Oh, were you looking to do this for more than one map at a time? It wasn't clear in the original post.&lt;/P&gt;&lt;P&gt;Also, is there a reason you need it to be broken by a newline?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 14:25:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1162089#M53769</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-04-07T14:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create a List of Layer from Map running into issues where instance has no attributes</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1162285#M53791</link>
      <description>&lt;P&gt;it's a little jank but I use FME to read in every map on an account then have it write out in python script then run the whole thing in arcgis pro so I know all of the layers for every map in our account. I needed a new line so when I copy and paste the output it goes into excel where the newline makes it easy to read.&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 19:54:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1162285#M53791</guid>
      <dc:creator>Kayden75</dc:creator>
      <dc:date>2022-04-07T19:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create a List of Layer from Map running into issues where instance has no attributes</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1241594#M63476</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;I have this code which is working with single item id. But I need to run this on all webmaps on my content or org. I am using notebook on AGOL&lt;BR /&gt;any idea how can I do this?&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from arcgis.gis import GIS
from arcgis.mapping import WebMap
gis = GIS('home')# if running this from Notebook for ArcGIS in AGOL/Enterprise, replace this line with gis = GIS('home')
wmItemId = "myid" #put the id of the webmap in here
wmItem = gis.content.get(wmItemId)
wm = WebMap(wmItem)
for lyr in wm.layers:
    print(lyr.title)
    print(lyr.url)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 15 Dec 2022 16:44:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/create-a-list-of-layer-from-map-running-into/m-p/1241594#M63476</guid>
      <dc:creator>anonymous55</dc:creator>
      <dc:date>2022-12-15T16:44:47Z</dc:date>
    </item>
  </channel>
</rss>

