Update surveys

This notebook uses the ArcGIS API for Python. For more information, see the ArcGIS API for Python documentation and guides.

This notebook demonstrates how to automate updating existing surveys through ArcGIS API for Python. You may want to automate updating your surveys for a variety of reasons. Examples are as follows:

  • Making schema modifications, such as adding or removing questions, adding repeats, or altering the form structure.
  • Updating assets used with your form, such as files in the media or scripts folders.
  • Updating surveys across organizations; for example, you've implemented new functionality in a survey located in your development environment and now are ready to push those changes to your production survey.

The first step is to connect to your GIS.

import arcgis
from arcgis.gis import GIS
gis = GIS("home")

Next, a SurveyManager is defined, and the survey to be updated is accessed using the form's item ID. A survey in the Survey Manager is a single instance of a survey 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 ArcGIS API for Python.

survey_manager = arcgis.apps.survey123.SurveyManager(gis)

survey = survey_manager.get("1a2bcd.....")

survey

Use the publish() method to publish changes to the Survey object. When updating a survey, the create_web_map parameter is ignored; it's only used for the initial publish.

To control how the method applies updates to the submission endpoint, use the schema_changes parameter. For more information on the schema_changes parameter please see the ArcGIS API for Python documentation.

In this example, the required xlsform parameter is set to the path where the XLSForm is located and optional parameters are set:

  • media is set to the path of the folder containing media to be used in the survey, and will add or update assets in the survey's media folder.
  • schema_changes is set to True so any form changes are applied that would require a change to the submission endpoint (feature service).
publish = survey.publish(
    xlsform=r"C:\<survey name.xlsx>",
    media=r"C:\media",
    schema_changes=True
)
publish

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.