<?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: Arcade script to split multi pick field values in ArcGIS Online Developers Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-developers-questions/arcade-script-to-split-multi-pick-field-values/m-p/1263715#M1210</link>
    <description>&lt;P&gt;Thank you so much, thank worked!&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2023 20:00:20 GMT</pubDate>
    <dc:creator>AndrewWallick</dc:creator>
    <dc:date>2023-03-02T20:00:20Z</dc:date>
    <item>
      <title>Arcade script to split multi pick field values</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/arcade-script-to-split-multi-pick-field-values/m-p/1263370#M1208</link>
      <description>&lt;P&gt;We have a working script to split apart values from a field that's the result of a multi-pick survey123 question.&amp;nbsp; The resulting table has three fields with a row for each answer, and we use the script in a Dashboard. We tried adjusting this script to work in a different dashboard with a different feature service, but it's only returning empty fields.&lt;/P&gt;&lt;P&gt;They seem to be doing the same things, and I believe the punctuation is all the same as well. The main difference I can see is the non-working script is trying to use a date field where the working script is using a second string field. So maybe this could be causing a problem. But if so, I'm not sure how to fix it.&lt;/P&gt;&lt;P&gt;Anyone have any idea?&lt;/P&gt;&lt;P&gt;Working Script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Write an expression that returns a FeatureSet.
// Documentation: https://arcg.is/3c419TD
// Samples: https://arcg.is/38SEWWz

// Reference layer using the FeatureSetByPortalItem() method.
var vportal = Portal('https://www.arcgis.com')
var fs = FeatureSetByPortalItem(
    vportal,
    '3b33e05c548a4688ba8852a1053f580b',
    0,
    ['severe_hazard_items_avail','City'],
    false
);
 
// Create empty array for features and feat object
var features = [];
var feat;

// Split comma separated hazard types and store in dictionary.
for (var vfeature in fs) {
    var split_array  =  Split(vfeature["severe_hazard_items_avail"], ',')
    var count_arr = Count(split_array)
    for(var i = 0; i &amp;lt; count_arr; i++ ){
        feat = {
            'attributes': {
                'split_choices': Trim(split_array[i]),
                'City':vfeature.City
            }
        }
        Push(features, feat);
}}

// Empty dictionary to capture each hazard as separate rows.
var choicesDict = {
    'fields': [
        { 'name': 'split_choices', 'type': 'esriFieldTypeString'},
        { 'name': 'City', 'type': 'esriFieldTypeString'}],
    'geometryType': '',
    'features': features
};

// Convert dictionary to featureSet.
var fs_dict = FeatureSet(Text(choicesDict));
return fs_dict&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Not working script:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Reference layer using the FeatureSetByPortalItem() method.
var vportal = Portal('https://www.arcgis.com')
var fs = FeatureSetByPortalItem(
vportal,
'd9ee252d54894d7980539078681775ee',
0,
['training_types', '_date'],
false
);

// Create empty array for features and feat object
var features = [];
var feat;

// Split comma separated hazard types and store in dictionary.
for (var vfeature in fs) {
var split_array = Split(vfeature["training_types"], ',')
var count_arr = Count(split_array)
for(var i = 0; i &amp;lt; count_arr; i++ ){
feat = {
'attributes': {
'split_choices': Trim(split_array[i]),
'_date':vfeature._date
}
}
Push(features, feat);
}}

// Empty dictionary to capture each choice as separate rows.
var choicesDict = {
'fields': [
{ 'name': 'split_choices', 'type': 'esriFieldTypeString'},
{ 'name': 'date', 'type': 'esriFieldTypeDate'}],
'geometryType': '',
'features': features
};

// Convert dictionary to featureSet.
var fs_dict = FeatureSet(Text(choicesDict));
return fs_dict&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 16:12:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/arcade-script-to-split-multi-pick-field-values/m-p/1263370#M1208</guid>
      <dc:creator>AndrewWallick</dc:creator>
      <dc:date>2023-03-02T16:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade script to split multi pick field values</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/arcade-script-to-split-multi-pick-field-values/m-p/1263405#M1209</link>
      <description>&lt;P&gt;To post code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1677736512957.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64138iBB0E7839D9513E0F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1677736512957.png" alt="JohannesLindner_0-1677736512957.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1677736529803.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64139i1EE5AE3E3AEE8247/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1677736529803.png" alt="JohannesLindner_1-1677736529803.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sadly, fields with type esriFieldTypeDate don't expect dates, but numbers. So you have to convert first:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;feat = {
    'attributes': {
        'split_choices': Trim(split_array[i]),
        '_date': Number(vfeature._date)
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a behavior that confuses a lot of users. I'm trying to get it fixed, please give your kudo to this idea:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-online-ideas/arcade-allow-date-values-in-date-fields/idi-p/1204894" target="_blank"&gt;Arcade: Allow Date() values in date fields (esriFi... - Esri Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 05:59:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/arcade-script-to-split-multi-pick-field-values/m-p/1263405#M1209</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-03-02T05:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade script to split multi pick field values</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/arcade-script-to-split-multi-pick-field-values/m-p/1263715#M1210</link>
      <description>&lt;P&gt;Thank you so much, thank worked!&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 20:00:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/arcade-script-to-split-multi-pick-field-values/m-p/1263715#M1210</guid>
      <dc:creator>AndrewWallick</dc:creator>
      <dc:date>2023-03-02T20:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade script to split multi pick field values</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/arcade-script-to-split-multi-pick-field-values/m-p/1299921#M1240</link>
      <description>&lt;P&gt;With this week's update to Arcade and ArcGIS Dashboards, this issue is fixed. Dates in feature sets now just work. You no longer have to wrap dates with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Number()&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;if you pass the dictionary into the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;FeatureSet()&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;function (which as of this release accepts a dictionary as opposed to only text based JSON).&lt;/P&gt;&lt;P&gt;Instead of:&lt;/P&gt;&lt;PRE&gt;return FeatureSet(Text(dict))&lt;/PRE&gt;&lt;P&gt;Do this:&lt;/P&gt;&lt;PRE&gt;return FeatureSet(dict)&lt;/PRE&gt;&lt;P&gt;Learn more on&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.esri.com/t5/arcgis-dashboards-blog/dashboard-data-expressions-what-has-changed-june/ba-p/1298782" target="_blank" rel="noopener"&gt;this blog post&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;NOTE: For Enterprise users, this update is targeted for 11.2&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 19:15:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/arcade-script-to-split-multi-pick-field-values/m-p/1299921#M1240</guid>
      <dc:creator>DavidNyenhuis1</dc:creator>
      <dc:date>2023-06-15T19:15:42Z</dc:date>
    </item>
  </channel>
</rss>

