<jupyter_start><jupyter_text>Work with the Survey Manager       Try it live        View source on GitHub   This notebook uses the ArcGIS API for Python. For more information, see the ArcGIS API for Python documentation and guides. As a survey owner, you may want to work with your ArcGIS Survey123 surveys via the ArcGIS API for Python to automate certain tasks, modify your surveys, or work with your surveys' data. This notebook demonstrates the different workflows for connecting to your surveys using the ArcGIS API for Python.The first way uses the form item's ID which is more precise and allows you to quickly get up and running with a specific survey. The second method shown performs a search against your content to identify form items. This method would be beneficial if you are looking to work with multiple surveys as a list. You can modify the search parameters to refine the list and only work with surveys that meet a specific criteria.<jupyter_code>import arcgis
from arcgis.gis import GIS
gis = GIS("home")<jupyter_output><empty_output><jupyter_text>Define a Survey ManagerNext, a Survey Manager is defined, a survey in the Survey Manager is a single instance of a survey project that contains the item information and properties and provides access to the underlying survey dataset. For more information on Survey Manager, see the API Reference for the ArcGIS API for Python.The code block below extracts all surveys in the Survey Manager as a list. The final statement prints the title for all surveys in the Survey Manager. The `'title'` property can be updated with any of the properties outlined in the Get survey by item section, below.<jupyter_code>survey_manager = arcgis.apps.survey123.SurveyManager(gis)
surveys = survey_manager.surveys
p = [print(s.properties['title']) for s in surveys]<jupyter_output>NIIT Reverse Geocode
NIIT Pre Enumeration Survey
schools
Pre-Enumeration Survey
Water Leak Report<jupyter_text>Get a surveyThere are two ways you can retrieve a survey:1. Use the Survey Manager to get a survey using its item ID.2. Use the GIS Content Manager to search for a survey.  Get survey by item IDIf one survey is of interest, you can use the `get` method to define a specific survey using the form's item ID. Using the `properties` method you can extract all, or specific properties associated with the form item.<jupyter_code>survey_by_id = survey_manager.get("9f01838a15594cfdbb2eb69fafb60d75")
print(survey_by_id)
print(survey_by_id.properties['title'])<jupyter_output><Survey @ Water Quality Inspection>
Water Quality Inspection<jupyter_text>Get survey by content searchThe code below uses the GIS Content Manager to search for a survey by owner. Returning the `forms` variable lists all the items identified (default is 10).<jupyter_code>forms = gis.content.search('type:form owner:NinjaGreen')
forms<jupyter_output><empty_output><jupyter_text>Using the `get` method you can extract a specific survey of interest using the index, and continue working with that object.   The ninth result, index 8, is then extracted from the results and the properties are returned.<jupyter_code>survey_by_item = survey_manager.get(forms[8])
print(survey_by_item.properties)<jupyter_output>{'id': '580747564c474cda835a918d0f97fa9a', 'owner': 'NinjaGreen', 'created': 1617153016000, 'isOrgItem': True, 'modified': 1617153016000, 'guid': None, 'name': 'Transmission_Tower.zip', 'title': 'Transmission Tower', 'type': 'Form', 'typeKeywords': ['Form', 'Survey123', 'Survey123 Connect', 'xForm'], 'description': 'Document transmission tower defects observed during routine inspections. This survey uses text, photos, sketches and annotation to capture details about defects.', 'tags': [], 'snippet': 'Record transmission tower defects', 'thumbnail': 'thumbnail/Transmission_Tower_Inspection.png', 'documentation': None, 'extent': [], 'categories': [], 'spatialReference': None, 'accessInformation': None, 'licenseInfo': None, 'culture': 'en-us', 'properties': None, 'url': None, 'proxyFilter': None, 'access': 'private', 'size': 103519, 'subInfo': 0, 'appCategories': [], 'industries': [], 'languages': [], 'largeThumbnail': None, 'banner': None, 'screenshots': [], 'listed': False, 'ownerFolder[...]<jupyter_text>Now that a survey has been identified from the Survey Manager let's do something with it. The code below creates a web map, specifies a basemap, and sets a default map scale. Using the survey identified previously, the survey's form item is obtained using the `get` method and its item ID. Next, the associated feature service is obtained and added to the web map. Finally, the web map with the survey data is displayed directly within the notebook.<jupyter_code>survey_webmap = gis.map('Maryland')
survey_webmap.basemap = 'dark-gray'
survey_webmap.zoom = 8
survey_service = gis.content.get(survey_by_item.properties['id'])
survey_webmap.add_layer(survey_service.related_items('Survey2Service','forward')[0])
survey_webmap<jupyter_output><empty_output>