Select to view content in your preferred language

Can you auto-populate a Survey123 pick list/drop down question from a Field Maps pop-up?

278
2
Jump to solution
02-24-2025 09:03 AM
KateSweet
Emerging Contributor

Hello,

I have been trying to link a Survey123 and FieldMap. I want a fieldworker to be able to click on the site in FieldMaps in a popup that links to Survey123 and then have one of the fields auto-populate with the data from the FieldMaps site that was clicked on to access the survey. The field in survey123 I want to auto-populate is a select one field, if that might matter. I have tried using the following url format in the popup in field maps: 
var url = "https://survey123.arcgis.app?itemID=IDHERE&field:name of field from Survey123 form={name of field in layer from survey123}";
return url;

Now when I open survey123 from the field map, I just see {name of field in layer from survey123}. Where did I go wrong? Or can you not auto-populate using this method in Survey123 dropdown menu questions?

Thank you for your thoughts.

 

0 Kudos
1 Solution

Accepted Solutions
AustinAverill
Frequent Contributor

The way I have accomplished before is through rich text (not using arcade).

For example I would add a text element, I would type something like "Submit Survey123" then highlight this and click the hyper link icon. In the hyper link for the text, you would enter your url formatted like this - 

https://survey123.arcgis.com/123456?field:survey_field={layer_field}

Then let the magic happen! 

 

If you wanted to accomplish this with arcade, you would still need to return rich text through an arcade element.

it would look something more like this:

// The base url for your survey
var base_url = "https://survey123.arcgis.com/123456"

// The field you are attempting to fill in your survey preceeded by "field:"
var survey_field = "field:field_name"

// The value you are attempting to fill that field with
var layer_value = $feature.layer_value

// The construction of the final url
var final_url = `${base_url}?${survey_field}=${layer_value}`
// Would produce "https://survey123.arcgis.com/123456?field:field_name=value"

// use the produced URL to construct the html
var html = `<a href = ${final_url}>Submit Survey123</a>`

// Construct the arcade text element to return
var element = {
    type : "text",
    text : html
}

return element

 

Note that in either method, the value from your layer must match the values source values in your drop down, not their display. For instance if you have a field that is filled with Yes or No for display values, but the underlying values are 1 and 0, your layer would need to fill in either 1 or 0.

View solution in original post

0 Kudos
2 Replies
AustinAverill
Frequent Contributor

The way I have accomplished before is through rich text (not using arcade).

For example I would add a text element, I would type something like "Submit Survey123" then highlight this and click the hyper link icon. In the hyper link for the text, you would enter your url formatted like this - 

https://survey123.arcgis.com/123456?field:survey_field={layer_field}

Then let the magic happen! 

 

If you wanted to accomplish this with arcade, you would still need to return rich text through an arcade element.

it would look something more like this:

// The base url for your survey
var base_url = "https://survey123.arcgis.com/123456"

// The field you are attempting to fill in your survey preceeded by "field:"
var survey_field = "field:field_name"

// The value you are attempting to fill that field with
var layer_value = $feature.layer_value

// The construction of the final url
var final_url = `${base_url}?${survey_field}=${layer_value}`
// Would produce "https://survey123.arcgis.com/123456?field:field_name=value"

// use the produced URL to construct the html
var html = `<a href = ${final_url}>Submit Survey123</a>`

// Construct the arcade text element to return
var element = {
    type : "text",
    text : html
}

return element

 

Note that in either method, the value from your layer must match the values source values in your drop down, not their display. For instance if you have a field that is filled with Yes or No for display values, but the underlying values are 1 and 0, your layer would need to fill in either 1 or 0.

0 Kudos
KateSweet
Emerging Contributor

Perfect, thank you! I found the rich text hyperlink to work great. 

0 Kudos