<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Populate select_one with values from JSON in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1077820#M35832</link>
    <description>&lt;P&gt;Oh! I see, you'd like the list of choices filtered, not just pre-selected. I think the only way to do this is to utilize the &lt;STRONG&gt;choice_filter &lt;/STRONG&gt;column. See: &lt;A href="https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-choice-filters/ba-p/894046" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-choice-filters/ba-p/894046&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I haven't combined a JS function and a choice filter before, but this is still doable using a hidden question and a choice filter.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Have you JS function return a comma-delimited string of choices&lt;OL&gt;&lt;LI&gt;"choice1,choice4,choice5"&lt;/LI&gt;&lt;LI&gt;This is the format of a select_multiple&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;In your &lt;STRONG&gt;choices&lt;/STRONG&gt; tab, create a column. I have named mine &lt;STRONG&gt;filt&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;Have the values in this column directly correspond to the choices themselves.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1626100941357.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/18227i929A7D76748C408C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1626100941357.png" alt="jcarlson_0-1626100941357.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;Create a hidden question that pulls in the string from your function. I've called mine &lt;STRONG&gt;strlist&lt;/STRONG&gt;. For testing, mine is just a text field, but it works the same when hidden.&lt;/LI&gt;&lt;LI&gt;In your select_one question, set the &lt;STRONG&gt;choice_filter &lt;/STRONG&gt;to &lt;STRONG&gt;selected(${strlist}, filt)&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Try it out!&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here's my test. You can see that my options are limited to those items in my string list.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_1-1626101193484.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/18228i7B2BF415AE757853/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_1-1626101193484.png" alt="jcarlson_1-1626101193484.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;EDIT: I should say, set that hidden question to a null type so it's not part of the output schema.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Jul 2021 14:49:49 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2021-07-12T14:49:49Z</dc:date>
    <item>
      <title>Populate select_one with values from JSON</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1077774#M35829</link>
      <description>&lt;P&gt;We have several survey forms with individual fields that are populated with the results returned by custom javascript.&amp;nbsp; We now have a need to populate a select_one dropdown with choices returned from a javascript function.&amp;nbsp; Is this possible in the latest version of Survey123?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 13:33:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1077774#M35829</guid>
      <dc:creator>GeoSolver</dc:creator>
      <dc:date>2021-07-12T13:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Populate select_one with values from JSON</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1077790#M35830</link>
      <description>&lt;P&gt;It &lt;EM&gt;should&lt;/EM&gt; be, but depends on what your function is returning. Are you able to share your code / xlsform?&lt;/P&gt;&lt;P&gt;In general, if your JS function is returning a simple string or numeric value, you can use &lt;STRONG&gt;pulldata("@javascript", "your-functions.js", "some-function", "parameter1", ... "parameterN")&lt;/STRONG&gt; right in the &lt;EM&gt;calculation&lt;/EM&gt; section of the XLSForm. As long as what your function returns corresponds with a defined choice for the question, this should work just fine.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 14:02:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1077790#M35830</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-07-12T14:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Populate select_one with values from JSON</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1077794#M35831</link>
      <description>&lt;P&gt;Thanks Josh.&amp;nbsp; Sorry I should have been more specific.&amp;nbsp; What I want to do is define the choices for the dropdown dynamically.&amp;nbsp; For example, in javascript I send the form's geopoint to the ArcGIS REST API, buffer the point 300ft and return all polygons from a feature service that intersect the buffer.&amp;nbsp; Then I want to define the choices in a dropdown with the attribute values from the returned list of polygons.&amp;nbsp; All of that already works except for the last part where the dropdown choices are defined.&amp;nbsp; So far I haven't found any syntax to use in the excel form that will override the choices that are static in the choices tab.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 14:06:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1077794#M35831</guid>
      <dc:creator>GeoSolver</dc:creator>
      <dc:date>2021-07-12T14:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: Populate select_one with values from JSON</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1077820#M35832</link>
      <description>&lt;P&gt;Oh! I see, you'd like the list of choices filtered, not just pre-selected. I think the only way to do this is to utilize the &lt;STRONG&gt;choice_filter &lt;/STRONG&gt;column. See: &lt;A href="https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-choice-filters/ba-p/894046" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-choice-filters/ba-p/894046&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I haven't combined a JS function and a choice filter before, but this is still doable using a hidden question and a choice filter.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Have you JS function return a comma-delimited string of choices&lt;OL&gt;&lt;LI&gt;"choice1,choice4,choice5"&lt;/LI&gt;&lt;LI&gt;This is the format of a select_multiple&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;In your &lt;STRONG&gt;choices&lt;/STRONG&gt; tab, create a column. I have named mine &lt;STRONG&gt;filt&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;Have the values in this column directly correspond to the choices themselves.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1626100941357.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/18227i929A7D76748C408C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1626100941357.png" alt="jcarlson_0-1626100941357.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;Create a hidden question that pulls in the string from your function. I've called mine &lt;STRONG&gt;strlist&lt;/STRONG&gt;. For testing, mine is just a text field, but it works the same when hidden.&lt;/LI&gt;&lt;LI&gt;In your select_one question, set the &lt;STRONG&gt;choice_filter &lt;/STRONG&gt;to &lt;STRONG&gt;selected(${strlist}, filt)&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Try it out!&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here's my test. You can see that my options are limited to those items in my string list.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_1-1626101193484.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/18228i7B2BF415AE757853/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_1-1626101193484.png" alt="jcarlson_1-1626101193484.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;EDIT: I should say, set that hidden question to a null type so it's not part of the output schema.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 14:49:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1077820#M35832</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-07-12T14:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: Populate select_one with values from JSON</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1077826#M35833</link>
      <description>&lt;P&gt;That is a slick way to filter a list of choices that already exist.&amp;nbsp; In my case, I would have to put 100's of thousands of choices into the spreadsheet to cover all the possibilities that are stored in the feature service.&amp;nbsp; What I am looking to do is dynamically define the choices without having to store any predefined values in the excel choice tab.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 14:56:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1077826#M35833</guid>
      <dc:creator>GeoSolver</dc:creator>
      <dc:date>2021-07-12T14:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: Populate select_one with values from JSON</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1077834#M35834</link>
      <description>&lt;P&gt;You'll probably want an &lt;A href="https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformessentials.htm#ESRI_SECTION1_34A4D88BA6A64C48AA0E113DC61099DD" target="_self"&gt;external choice list&lt;/A&gt;, then. I haven't worked with them much, but perhaps you could export your layer's vales from the relevant column(s) to a CSV?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 15:13:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1077834#M35834</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-07-12T15:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Populate select_one with values from JSON</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1265157#M47840</link>
      <description>&lt;P&gt;Hi, do you have find a solution ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 20:43:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/populate-select-one-with-values-from-json/m-p/1265157#M47840</guid>
      <dc:creator>JulienCHARBONNAUD</dc:creator>
      <dc:date>2023-03-07T20:43:19Z</dc:date>
    </item>
  </channel>
</rss>

