<?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: Search Returns Feature Layers name but not Layer name in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/search-returns-feature-layers-name-but-not-layer/m-p/1010981#M5341</link>
    <description>&lt;P&gt;Hi Joshua,&lt;/P&gt;&lt;P&gt;I spent ages, trying to get it to loop through the layers..&lt;/P&gt;&lt;P&gt;Thanks for your advice, much appreciated,&amp;nbsp; that provides the loop that I couldn't get working.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Clive&lt;/P&gt;</description>
    <pubDate>Fri, 18 Dec 2020 17:13:27 GMT</pubDate>
    <dc:creator>Clive_S</dc:creator>
    <dc:date>2020-12-18T17:13:27Z</dc:date>
    <item>
      <title>Search Returns Feature Layers name but not Layer name</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/search-returns-feature-layers-name-but-not-layer/m-p/1010191#M5329</link>
      <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;I have been battling trying to get each associated Layer name returned, for a&amp;nbsp;Feature Layer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have approx. 300 Feature Layers.&lt;/P&gt;&lt;P&gt;Looking at one Feature layer (Temporary Works) it has five layers (work extent, Roads Poly, Roads Line, Temp Roads, label Points).&amp;nbsp;I want to return the Feature layer (Temporary Works) which has five layers (work extent, Roads Poly, Roads Line, Temp Roads, label Points)&lt;/P&gt;&lt;P&gt;I want to Feature layer (Temporary Works) has five layers (work extent, Roads Poly, Roads Line, Temp Roads, label Points)&lt;/P&gt;&lt;P&gt;I want to return Feature Layer (id, url, Feature Layer name, layer url, layer name)&lt;/P&gt;&lt;P&gt;I get the (id, url, Feature Layer name) the Feature Layer name is returned five times, but I cannot get not the layer name.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code, I cannot get it to loop on FeatureName[0].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;all_users = portal.users.search(query='owner:*',  max_users = 700)  
groups = portal.content.search("*",  item_type="Feature*")

## output file
outFile = (r"C:\Users\user\Data Catalogue\Portal_TEST.csv")
with open(outFile, 'w', newline='') as csvfile:
    filewriter = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL)
    filewriter.writerow(['group_id', 'group_title', 'group_owner', 'item_id', 'item_type', 'item_url', 'item_title', 'item_name',  'item_owner' ])
    for group in groups:
        #    ### Prints the Group Name + Owner
        #    #print(group.title, group.owner)
        for user in all_users:
            #print(group.id, group.title, group.owner)
            #### List the Items in Portal
            content_item = user.items()
            for item in content_item:
                #item = content_item.item.name[0]
                #print(item)
                #print(item.url)
                #print(item)
                #print(item)
                print(group.id, group.title, group.owner, item.id, item.title, item.type, item.owner, item.url)
                rowitem = (group.id, group.title, group.owner, item.id, item.type, item.url, item.title, item.name, item.owner)
                filewriter.writerow(rowitem )

print("END")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get as an output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;1ab23ab12345670a12345678d1234567	Feature Service	https://my.com/server/rest/services/Temporary_Works/FeatureServer  Temporary_Works 	Temporary_Works
1ab23ab12345670a12345678d1234567	Feature Service	https://my.com/server/rest/services/Temporary_Works/FeatureServer  Temporary_Works 	Temporary_Works
1ab23ab12345670a12345678d1234567	Feature Service	https://my.com/server/rest/services/Temporary_Works/FeatureServer  Temporary_Works 	Temporary_Works
1ab23ab12345670a12345678d1234567	Feature Service	https://my.com/server/rest/services/Temporary_Works/FeatureServer  Temporary_Works 	Temporary_Works
1ab23ab12345670a12345678d1234567	Feature Service	https://my.com/server/rest/services/Temporary_Works/FeatureServer  Temporary_Works 	Temporary_Works&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate any pointers to return the Layer id and name.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Clive&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2020 16:25:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/search-returns-feature-layers-name-but-not-layer/m-p/1010191#M5329</guid>
      <dc:creator>Clive_S</dc:creator>
      <dc:date>2020-12-16T16:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Search Returns Feature Layers name but not Layer name</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/search-returns-feature-layers-name-but-not-layer/m-p/1010954#M5340</link>
      <description>&lt;P&gt;Hi Clive,&lt;/P&gt;&lt;P&gt;I'll admit I'm a little confused about your code, as I don't see any reference to&amp;nbsp;&lt;SPAN&gt;FeatureName[0] and your variable "groups" seems to be returning your feature layers? Also your output doesn't match what's in your "rowitem" at all?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Regardless, to access that information you need to access the FeatureLayer object properties, which gives you access to the name and id as a dictionary.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# this prints the dictionary with all of the extra info, flayer being a Feature Layer object
flayer.properties

# to print id and name respectively
flayer.properties["id"]
flayer.properties["name"]&lt;/LI-CODE&gt;&lt;P&gt;If your intention is to iterate over every feature layer and print out that information, I think the following code does it a bit more efficiently.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;serviceItems = gis.content.search("*",  item_type="Feature*", max_items=1000)
for item in serviceItems:
    layers = item.layers
    for lyr in layers:
        try:
            print(item.id, item.url, lyr.properties["id"], lyr.properties["name"])
        except Exception as e:
            print(e)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 18 Dec 2020 16:08:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/search-returns-feature-layers-name-but-not-layer/m-p/1010954#M5340</guid>
      <dc:creator>JoshuaSharp-Heward</dc:creator>
      <dc:date>2020-12-18T16:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Search Returns Feature Layers name but not Layer name</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/search-returns-feature-layers-name-but-not-layer/m-p/1010981#M5341</link>
      <description>&lt;P&gt;Hi Joshua,&lt;/P&gt;&lt;P&gt;I spent ages, trying to get it to loop through the layers..&lt;/P&gt;&lt;P&gt;Thanks for your advice, much appreciated,&amp;nbsp; that provides the loop that I couldn't get working.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Clive&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 17:13:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/search-returns-feature-layers-name-but-not-layer/m-p/1010981#M5341</guid>
      <dc:creator>Clive_S</dc:creator>
      <dc:date>2020-12-18T17:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Search Returns Feature Layers name but not Layer name</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/search-returns-feature-layers-name-but-not-layer/m-p/1011000#M5342</link>
      <description>&lt;P&gt;No worries Clive, Glad I could help out!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 17:49:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/search-returns-feature-layers-name-but-not-layer/m-p/1011000#M5342</guid>
      <dc:creator>JoshuaSharp-Heward</dc:creator>
      <dc:date>2020-12-18T17:49:08Z</dc:date>
    </item>
  </channel>
</rss>

