Pulldata to autocomplete from another layer

346
3
Jump to solution
08-26-2024 07:35 AM
agroges362
New Contributor

Hello,

I have two surveys created in Survey123 where one will be completed first, and only after that, the second one will be launched. What I intend to do is have a repeat with the number of repeats determined based on a multiple-choice response from the first survey.

I understand that with the repeat count, it's possible to set a fixed number of repeats by asking a question beforehand. However, what I couldn't manage was configuring this question using the pulldata function with the URL of the first survey—it always returns an error. The message I receive is: "There has been a problem trying to replace ${…..} with the XPath to the survey element named. There is no survey element with this name."

Does the pulldata function have an issue with retrieving information from a feature layer (hosted) ? Would I need to create a script for these types of conditions?

Thank you!

0 Kudos
1 Solution

Accepted Solutions
ToddW_stl
Esri Contributor

Thanks!  I think you simply have a couple syntax errors in your pulldata calculation.  When referencing a survey question/value, use the ${name} syntax.  When referencing the field in your service, use "attributes.fieldName". 

Replace "${count_crops}" in your pulldata calc with (case sensitive) "attributes.count_crops" -

and for the farm_id query, see the pulldata tips on concat and SQL here and some of the examples for request parameters

There are also many great Samples to review in Survey123 Connect; "Multiple Choice Questions" may be of interest to you!

View solution in original post

0 Kudos
3 Replies
ToddW_stl
Esri Contributor

hi @agroges362 - Can you share your XLSForm(s)?  According to the docs, you should be able to use a calculation (pulldata) to set the repeat count. You may not have meant this when you wrote "pulldata function with the URL of the first survey", but ensure you're pulling data from the FeatureServer.  I'd also check that the pulldata is returning a numeric value from a numeric fieldtype and that submission url is correct and accurate in the settings tab of the second survey if you're calculating a count from repeat records in the first survey.  You should be able to use the count-selected formula in both to return an integer.

0 Kudos
agroges362
New Contributor

the 'repeats funcion_test' is from survey nr 1 and the 'Part II_test_repeatsFunction' is from survey nr 2.  I've checked the field types from both and seems to be correct.

Thank you!

0 Kudos
ToddW_stl
Esri Contributor

Thanks!  I think you simply have a couple syntax errors in your pulldata calculation.  When referencing a survey question/value, use the ${name} syntax.  When referencing the field in your service, use "attributes.fieldName". 

Replace "${count_crops}" in your pulldata calc with (case sensitive) "attributes.count_crops" -

and for the farm_id query, see the pulldata tips on concat and SQL here and some of the examples for request parameters

There are also many great Samples to review in Survey123 Connect; "Multiple Choice Questions" may be of interest to you!

0 Kudos