Select to view content in your preferred language

Does the python Suvey 123 api support creating a new survey referencing an existing feature service using submission_url

337
3
3 weeks ago
ashcom
by
Emerging Contributor

Hi,

I've been using Survey123 connect for quite some time but I'm currently exploring the python API with the view to automating the creation of a surveys using the arcgis.apps.survey123 module | ArcGIS API for Python | Esri Developer sub module.

I 've been able to successfully publish a new survey (whereby creating an associated hosted service). I've also been able to update an existing survey that was created via Survey123 connect using the publish method.

What I'd like to do, is programmatically create a survey that references an existing feature service, effectively replicating the workflow you can use in survey 123 connect where you create a survey from a feature service.

Is this actually supported?

If I run the create method it always seems to create an associated feature service, which I don't want to do. I want to reference the feature service in the submission_url of the .xlsform

Thanks.

3 Replies
CoMAGOL_ADMINISTRATOR
Regular Contributor

Hi,

FYI, this is the response from ESRI as of May 26':

Using the existing Survey123 Python API, there isn’t another supported way to programmatically “create a survey from an existing feature service” (i.e., generate the XLSForm from the service), like Survey123 Connect does. That “Create a survey from a feature layer” workflow is documented for Survey123 Connect.
Source: Use Survey123 with existing feature layers—ArcGIS Survey123

With Python, the supported pattern is to publish/update from an XLSForm (and that XLSForm can be configured to submit to an existing feature layer by setting submission_url/form_id), but the API does not provide a “create-from-feature-service” method.
Source: arcgis.apps.survey123 module | ArcGIS API for Python | Esri Developer 

LennardLux
Occasional Contributor

Is publishing XLSForms that contain repeats supported in this version of the ArcGIS API for Python?

When I tried to publish a survey with repeats that points to an existing feature service (a view in this case) in my Portal for ArcGIS instance:

published = new_survey.publish(
                xlsform=xlsform,
                schema_changes=False,       
                create_web_map=False,       
                enable_delete_protection=False,
            )

I'm getting this error:

{
  "<PARENT_TABLE> Errors": {},
  "<CHILD_TABLE> Errors": {
    "Field Errors": [
      "Field not found in the feature service for the globalid question.",
      "Field not found in the feature service for the parentglobalid question."
    ]
  }

 

0 Kudos
ZacharySutherby
Esri Regular Contributor

Hey @ashcom

Can you please verify what version of the ArcGIS API for Python you are using? 

 

@CoMAGOL_ADMINISTRATOR is correct regarding no method in the Python API to create a new survey from existing feature layer. Since there are considerable form configuration options beyond just mapping field types from a feature layer to question types in a survey your script would need to configure the XLSForm how you need. Including things such as appearances for questions, calculations, relevant logic, etc. Then pass that configured XLSForm into the publish() method. 

 

Would you be able to provide additional information on how you would like to use a “create-from-feature-service” method in the Python API? Would you want a submission_url and form_id as input parameters for the create() method and an output from the create() method being a barebones XLSForm that does field type to question type mapping like creating from a feature layer in Connect? 

 

Regarding the error: 

{
  "<PARENT_TABLE> Errors": {},
  "<CHILD_TABLE> Errors": {
    "Field Errors": [
      "Field not found in the feature service for the globalid question.",
      "Field not found in the feature service for the parentglobalid question."
    ]
  }

Assuming you are using a version of the Python API greater than 2.4.0 and are seeing this error, this would be a defect in the publish() method. 

It looks like your feature layer has a related layer/table that either has different field names for the global ID based relationships or does not use global ID based relationships. 

 

Would you be able to share a bit more about the schema of your feature layer? 

Thank you,
Zach
0 Kudos