<?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 Arcade Data Expression runs in playground but not in &amp;quot;live&amp;quot; dashboard in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-runs-in-playground-but-not/m-p/1301640#M7985</link>
    <description>&lt;P&gt;Hello -&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to list averages from featureset variables and display them in a list. My script runs in the ArcCade or "Data Expression" playground but when I try to use it for an element on my dashboard it shows a message "unable to execute script".&amp;nbsp; What am I doing wrong?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var p = 'https://xxxx.maps.arcgis.com/';
var itemId = '&amp;lt;layer id goes here&amp;gt;';
var fs = FeatureSetByPortalItem(Portal(p), itemId, 0, ['judgename','totalscore_stu1','totalscore_stu2','totalscore_stu3','totalscore_stu4','totalscore_stu5','totalscore_stu6'], false);
var scoreStu1 = Average(fs, 'totalscore_stu1');
var scoreStu2 = Average(fs, 'totalscore_stu2');
var scoreStu3 = Average(fs, 'totalscore_stu3');
var scoreStu4 = Average(fs, 'totalscore_stu4');
var scoreStu5 = Average(fs, 'totalscore_stu5');
var scoreStu6 = Average(fs, 'totalscore_stu6');

var result = [
  { "Name": "scoreStu1", "Score": scoreStu1 },
  { "Name": "scoreStu2", "Score": scoreStu2 },
  { "Name": "scoreStu3", "Score": scoreStu3 },
  { "Name": "scoreStu4", "Score": scoreStu4 },
  { "Name": "scoreStu5", "Score": scoreStu5 },
  { "Name": "scoreStu6", "Score": scoreStu6 }
];

return result;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance for any guidance!&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jun 2023 16:55:08 GMT</pubDate>
    <dc:creator>JamiDennis</dc:creator>
    <dc:date>2023-06-21T16:55:08Z</dc:date>
    <item>
      <title>Arcade Data Expression runs in playground but not in "live" dashboard</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-runs-in-playground-but-not/m-p/1301640#M7985</link>
      <description>&lt;P&gt;Hello -&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to list averages from featureset variables and display them in a list. My script runs in the ArcCade or "Data Expression" playground but when I try to use it for an element on my dashboard it shows a message "unable to execute script".&amp;nbsp; What am I doing wrong?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var p = 'https://xxxx.maps.arcgis.com/';
var itemId = '&amp;lt;layer id goes here&amp;gt;';
var fs = FeatureSetByPortalItem(Portal(p), itemId, 0, ['judgename','totalscore_stu1','totalscore_stu2','totalscore_stu3','totalscore_stu4','totalscore_stu5','totalscore_stu6'], false);
var scoreStu1 = Average(fs, 'totalscore_stu1');
var scoreStu2 = Average(fs, 'totalscore_stu2');
var scoreStu3 = Average(fs, 'totalscore_stu3');
var scoreStu4 = Average(fs, 'totalscore_stu4');
var scoreStu5 = Average(fs, 'totalscore_stu5');
var scoreStu6 = Average(fs, 'totalscore_stu6');

var result = [
  { "Name": "scoreStu1", "Score": scoreStu1 },
  { "Name": "scoreStu2", "Score": scoreStu2 },
  { "Name": "scoreStu3", "Score": scoreStu3 },
  { "Name": "scoreStu4", "Score": scoreStu4 },
  { "Name": "scoreStu5", "Score": scoreStu5 },
  { "Name": "scoreStu6", "Score": scoreStu6 }
];

return result;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance for any guidance!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 16:55:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-runs-in-playground-but-not/m-p/1301640#M7985</guid>
      <dc:creator>JamiDennis</dc:creator>
      <dc:date>2023-06-21T16:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Data Expression runs in playground but not in "live" dashboard</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-runs-in-playground-but-not/m-p/1301673#M7986</link>
      <description>&lt;P&gt;The playground will return &lt;EM&gt;anything&lt;/EM&gt; provided it's a valid object. A data expression is specifically looking for a &lt;STRONG&gt;FeatureSet&lt;/STRONG&gt;, which your result is not. You have an array of objects, but you need to built them into a FeatureSet as follows:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var p = 'https://xxxx.maps.arcgis.com/';
var itemId = '&amp;lt;layer id goes here&amp;gt;';
var fs = FeatureSetByPortalItem(Portal(p), itemId, 0, ['judgename','totalscore_stu1','totalscore_stu2','totalscore_stu3','totalscore_stu4','totalscore_stu5','totalscore_stu6'], false);

var scoreStu1 = Average(fs, 'totalscore_stu1');
var scoreStu2 = Average(fs, 'totalscore_stu2');
var scoreStu3 = Average(fs, 'totalscore_stu3');
var scoreStu4 = Average(fs, 'totalscore_stu4');
var scoreStu5 = Average(fs, 'totalscore_stu5');
var scoreStu6 = Average(fs, 'totalscore_stu6');

var result = [
  { attributes: { "Name": "scoreStu1", "Score": scoreStu1 }},
  { attributes: { "Name": "scoreStu2", "Score": scoreStu2 }},
  { attributes: { "Name": "scoreStu3", "Score": scoreStu3 }},
  { attributes: { "Name": "scoreStu4", "Score": scoreStu4 }},
  { attributes: { "Name": "scoreStu5", "Score": scoreStu5 }},
  { attributes: { "Name": "scoreStu6", "Score": scoreStu6 }}
];

var out_dict = {
  fields: [
    { name: 'scoreStu1', type: 'esriFieldTypeDouble' },
    { name: 'scoreStu2', type: 'esriFieldTypeDouble' },
    { name: 'scoreStu3', type: 'esriFieldTypeDouble' },
    { name: 'scoreStu4', type: 'esriFieldTypeDouble' },
    { name: 'scoreStu5', type: 'esriFieldTypeDouble' },
    { name: 'scoreStu6', type: 'esriFieldTypeDouble' }
  ],
  geometryType: '',
  features: result
}

return FeatureSet(out_dict)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 21 Jun 2023 17:49:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-runs-in-playground-but-not/m-p/1301673#M7986</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-06-21T17:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Data Expression runs in playground but not in "live" dashboard</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-runs-in-playground-but-not/m-p/1301680#M7987</link>
      <description>&lt;P&gt;Thank you!! This got me almost exactly what I needed. Just had to rewrite the out_dict to this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var out_dict = {
  fields: [
    { name: 'Name', type: 'esriFieldTypeString' },
    { name: 'Score', type: 'esriFieldTypeDouble' }
  ],
  geometryType: '',
  features: result
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 21 Jun 2023 18:00:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-runs-in-playground-but-not/m-p/1301680#M7987</guid>
      <dc:creator>JamiDennis</dc:creator>
      <dc:date>2023-06-21T18:00:45Z</dc:date>
    </item>
  </channel>
</rss>

