<?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 SWEET for ArcGIS  Arcade - Create dropdown list for a field based on a hosted table in ArcGIS Online Developers Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-developers-questions/sweet-for-arcgis-arcade-create-dropdown-list-for-a/m-p/1159207#M1109</link>
    <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am building an application in SWEET for ArcGIS and want to create a dynamic drop down list for a field. I want the options to show possible values based on a hosted lookup table; basically a dynamic domain. I can't actually use a domain so I need to figure out how to do this...&lt;/P&gt;&lt;P&gt;There is an example in SWEET for creating a static list of possible values, but I'm not sure how to do this by reading off a table. In python, I would read the table, and for each record in the field, I'd add the value to the list. Then I would return the list, and those would be the options.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not really sure how to achieve this in Arcade, it seems like it uses "arrays" instead of "lists" for this functionality. How do I add values to an array in Arcade?&lt;/P&gt;&lt;P&gt;Here's how I wish the script would work...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var TestingPolicies = FeatureSetByName($map,"Testingpolicy")
var options = []//create empty list
for (var record in TestingPolicies){
    var option = record.DCA_Type
    options.append(option)//add each option to the list
}
return options&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here's the sample code for making a 'static' list using the SWEET configuration "Scripted Choice for [Field Name]":&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;return {
  choices: [
    {
      value: "A",
      label: "AAA"
    },
    {
      value: "B",
      label: "BBB"
    },
    {
      value: "C",
      label: "CCC"
    }
  ],
  static: true // If static, the script will only ever execute once. Use for lists that do not change
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Mar 2022 01:12:40 GMT</pubDate>
    <dc:creator>Kaz</dc:creator>
    <dc:date>2022-03-30T01:12:40Z</dc:date>
    <item>
      <title>SWEET for ArcGIS  Arcade - Create dropdown list for a field based on a hosted table</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/sweet-for-arcgis-arcade-create-dropdown-list-for-a/m-p/1159207#M1109</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am building an application in SWEET for ArcGIS and want to create a dynamic drop down list for a field. I want the options to show possible values based on a hosted lookup table; basically a dynamic domain. I can't actually use a domain so I need to figure out how to do this...&lt;/P&gt;&lt;P&gt;There is an example in SWEET for creating a static list of possible values, but I'm not sure how to do this by reading off a table. In python, I would read the table, and for each record in the field, I'd add the value to the list. Then I would return the list, and those would be the options.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not really sure how to achieve this in Arcade, it seems like it uses "arrays" instead of "lists" for this functionality. How do I add values to an array in Arcade?&lt;/P&gt;&lt;P&gt;Here's how I wish the script would work...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var TestingPolicies = FeatureSetByName($map,"Testingpolicy")
var options = []//create empty list
for (var record in TestingPolicies){
    var option = record.DCA_Type
    options.append(option)//add each option to the list
}
return options&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here's the sample code for making a 'static' list using the SWEET configuration "Scripted Choice for [Field Name]":&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;return {
  choices: [
    {
      value: "A",
      label: "AAA"
    },
    {
      value: "B",
      label: "BBB"
    },
    {
      value: "C",
      label: "CCC"
    }
  ],
  static: true // If static, the script will only ever execute once. Use for lists that do not change
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 01:12:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/sweet-for-arcgis-arcade-create-dropdown-list-for-a/m-p/1159207#M1109</guid>
      <dc:creator>Kaz</dc:creator>
      <dc:date>2022-03-30T01:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: SWEET for ArcGIS  Arcade - Create dropdown list for a field based on a hosted table</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/sweet-for-arcgis-arcade-create-dropdown-list-for-a/m-p/1159249#M1110</link>
      <description>&lt;P&gt;I have no clue about SWEET and if this will work, but you're looking for the &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#push" target="_blank" rel="noopener"&gt;Push&lt;/A&gt; function.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var TestingPolicies = FeatureSetByName($map,"Testingpolicy")
// if you have multiples of each DCA_Type in that table, you might want to use Distinct:
//TestingPolicies = Distinct(TestingPolicies, "DCA_Type")
var options = []//create empty list
for (var record in TestingPolicies){
    var option = record.DCA_Type
    Push(options, option)//add each option to the list
}
return options&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 30 Mar 2022 07:24:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/sweet-for-arcgis-arcade-create-dropdown-list-for-a/m-p/1159249#M1110</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-03-30T07:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: SWEET for ArcGIS  Arcade - Create dropdown list for a field based on a hosted table</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/sweet-for-arcgis-arcade-create-dropdown-list-for-a/m-p/1573403#M1545</link>
      <description>&lt;P&gt;Hi Johannes,&lt;/P&gt;&lt;P&gt;I have used a similar expression however it returns the array as a whole, not the individual values in a pickable list.&amp;nbsp; Any idea if there is a way to make the values in the array selectable in a picklist?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;Darryl&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 01:01:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/sweet-for-arcgis-arcade-create-dropdown-list-for-a/m-p/1573403#M1545</guid>
      <dc:creator>DarrylAlbert</dc:creator>
      <dc:date>2025-01-08T01:01:38Z</dc:date>
    </item>
  </channel>
</rss>

