<?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: Iterate all Survey123s in a portal to get FeatureLayer for each in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/iterate-all-survey123s-in-a-portal-to-get/m-p/1413088#M9912</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/573916"&gt;@Dirk_Vandervoort&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not got a lot of Forms to test this but here is an option using the related_items() method for an item object.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

## access agol
gis = GIS("home")

## get all forms
my_S123s = gis.content.search(query="type: Form", max_items=1000)

## iterate through all forms
for s123 in my_S123s:
    ## get form as an item object
    sform = gis.content.get(s123.id)
    ## assumes one feature layer per feature service
    ## you could iterate over feature layers instead to access all
    ## https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.related_items
    ## https://developers.arcgis.com/rest/users-groups-and-items/relationship-types.htm
    ## related_items returns a list
    aFLay = sform.related_items("Survey2Service")[0].layers[0]
    print(aFLay.properties)&lt;/LI-CODE&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
    <pubDate>Sun, 21 Apr 2024 10:38:45 GMT</pubDate>
    <dc:creator>Clubdebambos</dc:creator>
    <dc:date>2024-04-21T10:38:45Z</dc:date>
    <item>
      <title>Iterate all Survey123s in a portal to get FeatureLayer for each</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/iterate-all-survey123s-in-a-portal-to-get/m-p/1412936#M9911</link>
      <description>&lt;P&gt;Here's the code:&lt;/P&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;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from arcgis.apps.survey123 import SurveyManager
from arcgis.features import FeatureLayer
gis = GIS() 
survey_manager = SurveyManager(gis)
my_S123s = gis.content.search(query="type: Form", max_items=1000) # "Form" guarantees a Survey123

for s123 in my_S123s:
    the_survey = survey_manager.get(s123.itemid)
    aFLay = FeatureLayer(the_survey.parent_fl_url, gis)
    # do something with aFLay
    the_survey = None&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see, I am looping through all Survey123 Form items in my GIS, creating a Survey123, then creating a FeatureLayer using the parent_fl_id of the Survey123.&lt;/P&gt;&lt;P&gt;Performance is&amp;nbsp;&lt;STRONG&gt;terrible. &lt;/STRONG&gt;I expect to be able whip through them. I'm looking for a more efficient way to get from Survey123 to FeatureLayer.&lt;/P&gt;&lt;P&gt;How can I get the Feature Layer from the Survey123 Form without so much pain and suffering.&lt;/P&gt;&lt;P&gt;As always, TIA.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Apr 2024 03:30:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/iterate-all-survey123s-in-a-portal-to-get/m-p/1412936#M9911</guid>
      <dc:creator>Dirk_Vandervoort</dc:creator>
      <dc:date>2024-04-21T03:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate all Survey123s in a portal to get FeatureLayer for each</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/iterate-all-survey123s-in-a-portal-to-get/m-p/1413088#M9912</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/573916"&gt;@Dirk_Vandervoort&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not got a lot of Forms to test this but here is an option using the related_items() method for an item object.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

## access agol
gis = GIS("home")

## get all forms
my_S123s = gis.content.search(query="type: Form", max_items=1000)

## iterate through all forms
for s123 in my_S123s:
    ## get form as an item object
    sform = gis.content.get(s123.id)
    ## assumes one feature layer per feature service
    ## you could iterate over feature layers instead to access all
    ## https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.related_items
    ## https://developers.arcgis.com/rest/users-groups-and-items/relationship-types.htm
    ## related_items returns a list
    aFLay = sform.related_items("Survey2Service")[0].layers[0]
    print(aFLay.properties)&lt;/LI-CODE&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Sun, 21 Apr 2024 10:38:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/iterate-all-survey123s-in-a-portal-to-get/m-p/1413088#M9912</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2024-04-21T10:38:45Z</dc:date>
    </item>
  </channel>
</rss>

