<?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 Error returning FeatureSet from data expression in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/error-returning-featureset-from-data-expression/m-p/1396011#M9271</link>
    <description>&lt;P&gt;I have a data expression that I have created using &lt;A href="https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/JoinLayerFieldsToTable.md" target="_blank" rel="noopener"&gt;this&lt;/A&gt; example along with several other posts found in the community. I believe everything is successful until the end when I try to return the dictionary as a feature set as can be seen in the console, but the out put is an error: '&lt;SPAN&gt;Test execution error: Unknown Error. Verify test data.'&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var portal = Portal("https://www.arcgis.com/");

var points = FeatureSetByPortalItem(
    portal,
    "273c4643a28e4d92a7dc607edbc54622",
    0,
    ["*"],
    false
);

var table = FeatureSetByPortalItem(
    portal,
    "273c4643a28e4d92a7dc607edbc54622",
    1,
    ["*"],
    false
);


var features = [];
var feat;

for (var t in table){
  var tableID = t["Parent_GUID"]
  for (var p in Filter(points, "GlobalID = @tableID")){
    Console('Populating attributes for: ' + tableID)
    feat = {
      attributes: {
        Sample_Date : t["Sample_Date"],
        Site: t["Site"],
        Description: p["Desc_"],
        Rel_Depth : t["Rel_Depth"],
        Weather: t["Weather"],
        Cloud_Cover: t["Cloud_Cover"],
        Wind : t["Wind"],
        Wind_Dir: t["Wind_Dir"],
        Air_Temp: t["Air_Temp"],
        Water_Temp: t["Water_Temp"],
        DO_Percent: t["DO_Percent"],
        DO_Concentration : t["DO_Concentration"],
        Conductivity: t["Conductivity"],
        Salinity: t["Salinity"],
        pH: t["pH"],
        Water_Depth: t["Water_Depth"],
        Turbidity: t["Turbidity"],
        Secchi: t["Secchi"],
        Chl_a: t["Chl_a"],
        NOx: t["NOx"],
        NO2: t["NO2"],
        NH4: t["NH4"],
        DIP: t["DIP"], 
        LA: t["LA"],
        Color: t["Color"],
        TSS: t["TSS"],
        Entero: t["Entero"],
        TKN: t["TKN"],
        TP: t["TP"],
      }
    }
  Console("Pushing data to feature array: " + feat + TextFormatting.NewLine)
  Push(features, feat)
  } 
}
Console('Feature array created')

Console("Creating dictionary")
var joinedDict = {
    fields: [
        { name: "Sample_Date", type: "esriFieldTypeDate" },
        { name: "Site", type: "esriFieldTypeString" },
        { name: "Description", type: "esriFieldTypeString" },
        { name: "Rel_Depth", type: "esriFieldTypeString" },
        { name: "Weather", type: "esriFieldTypeString" },
        { name: "Cloud_Cover", type:" esriFieldTypeInteger" },
        { name: "Wind", type: "esriFieldTypeDouble" },
        { name: "Wind_Dir", type: "esriFieldTypeInteger" },
        { name: "Air_Temp", type: "esriFieldTypeDouble" },
        { name: "Water_Temp", type: "esriFieldTypeDouble" },
        { name: "DO_Percent", type: "esriFieldTypeDouble" },
        { name: "DO_Concentration", type: "esriFieldTypeDouble" },
        { name: "Conductivity", type: "esriFieldTypeInteger" },
        { name: "Salinity", type: "esriFieldTypeDouble" },
        { name: "pH", type: "esriFieldTypeDouble" },
        { name: "Water_Depth", type: "esriFieldTypeDouble" },
        { name: "Turbidity", type: "esriFieldTypeDouble" },
        { name: "Secchi", type: "esriFieldTypeString" },
        { name: "Chl_a", type: "esriFieldTypeDouble" },
        { name: "NOx", type: "esriFieldTypeDouble" },
        { name: "NO2", type: "esriFieldTypeDouble" },
        { name: "NH4", type: "esriFieldTypeDouble" },
        { name: "DIP", type: "esriFieldTypeDouble" },
        { name: "LA", type: "esriFieldTypeDouble" },
        { name: "Color", type: "esriFieldTypeDouble" },
        { name: "TSS", type: "esriFieldTypeDouble" },
        { name: "Entero", type: "esriFieldTypeInteger" },
        { name: "TKN", type: "esriFieldTypeDouble" },
        { name: "TP", type: "esriFieldTypeDouble" }
        ],
    'geometryType': '',
    'features': features
};

Console('Data dictionary created, print to console: ' + TextFormatting.NewLine)
Console(joinedDict)

return FeatureSet(Text(joinedDict));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Mar 2024 16:05:00 GMT</pubDate>
    <dc:creator>MFazio</dc:creator>
    <dc:date>2024-03-14T16:05:00Z</dc:date>
    <item>
      <title>Error returning FeatureSet from data expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/error-returning-featureset-from-data-expression/m-p/1396011#M9271</link>
      <description>&lt;P&gt;I have a data expression that I have created using &lt;A href="https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/JoinLayerFieldsToTable.md" target="_blank" rel="noopener"&gt;this&lt;/A&gt; example along with several other posts found in the community. I believe everything is successful until the end when I try to return the dictionary as a feature set as can be seen in the console, but the out put is an error: '&lt;SPAN&gt;Test execution error: Unknown Error. Verify test data.'&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var portal = Portal("https://www.arcgis.com/");

var points = FeatureSetByPortalItem(
    portal,
    "273c4643a28e4d92a7dc607edbc54622",
    0,
    ["*"],
    false
);

var table = FeatureSetByPortalItem(
    portal,
    "273c4643a28e4d92a7dc607edbc54622",
    1,
    ["*"],
    false
);


var features = [];
var feat;

for (var t in table){
  var tableID = t["Parent_GUID"]
  for (var p in Filter(points, "GlobalID = @tableID")){
    Console('Populating attributes for: ' + tableID)
    feat = {
      attributes: {
        Sample_Date : t["Sample_Date"],
        Site: t["Site"],
        Description: p["Desc_"],
        Rel_Depth : t["Rel_Depth"],
        Weather: t["Weather"],
        Cloud_Cover: t["Cloud_Cover"],
        Wind : t["Wind"],
        Wind_Dir: t["Wind_Dir"],
        Air_Temp: t["Air_Temp"],
        Water_Temp: t["Water_Temp"],
        DO_Percent: t["DO_Percent"],
        DO_Concentration : t["DO_Concentration"],
        Conductivity: t["Conductivity"],
        Salinity: t["Salinity"],
        pH: t["pH"],
        Water_Depth: t["Water_Depth"],
        Turbidity: t["Turbidity"],
        Secchi: t["Secchi"],
        Chl_a: t["Chl_a"],
        NOx: t["NOx"],
        NO2: t["NO2"],
        NH4: t["NH4"],
        DIP: t["DIP"], 
        LA: t["LA"],
        Color: t["Color"],
        TSS: t["TSS"],
        Entero: t["Entero"],
        TKN: t["TKN"],
        TP: t["TP"],
      }
    }
  Console("Pushing data to feature array: " + feat + TextFormatting.NewLine)
  Push(features, feat)
  } 
}
Console('Feature array created')

Console("Creating dictionary")
var joinedDict = {
    fields: [
        { name: "Sample_Date", type: "esriFieldTypeDate" },
        { name: "Site", type: "esriFieldTypeString" },
        { name: "Description", type: "esriFieldTypeString" },
        { name: "Rel_Depth", type: "esriFieldTypeString" },
        { name: "Weather", type: "esriFieldTypeString" },
        { name: "Cloud_Cover", type:" esriFieldTypeInteger" },
        { name: "Wind", type: "esriFieldTypeDouble" },
        { name: "Wind_Dir", type: "esriFieldTypeInteger" },
        { name: "Air_Temp", type: "esriFieldTypeDouble" },
        { name: "Water_Temp", type: "esriFieldTypeDouble" },
        { name: "DO_Percent", type: "esriFieldTypeDouble" },
        { name: "DO_Concentration", type: "esriFieldTypeDouble" },
        { name: "Conductivity", type: "esriFieldTypeInteger" },
        { name: "Salinity", type: "esriFieldTypeDouble" },
        { name: "pH", type: "esriFieldTypeDouble" },
        { name: "Water_Depth", type: "esriFieldTypeDouble" },
        { name: "Turbidity", type: "esriFieldTypeDouble" },
        { name: "Secchi", type: "esriFieldTypeString" },
        { name: "Chl_a", type: "esriFieldTypeDouble" },
        { name: "NOx", type: "esriFieldTypeDouble" },
        { name: "NO2", type: "esriFieldTypeDouble" },
        { name: "NH4", type: "esriFieldTypeDouble" },
        { name: "DIP", type: "esriFieldTypeDouble" },
        { name: "LA", type: "esriFieldTypeDouble" },
        { name: "Color", type: "esriFieldTypeDouble" },
        { name: "TSS", type: "esriFieldTypeDouble" },
        { name: "Entero", type: "esriFieldTypeInteger" },
        { name: "TKN", type: "esriFieldTypeDouble" },
        { name: "TP", type: "esriFieldTypeDouble" }
        ],
    'geometryType': '',
    'features': features
};

Console('Data dictionary created, print to console: ' + TextFormatting.NewLine)
Console(joinedDict)

return FeatureSet(Text(joinedDict));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 16:05:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/error-returning-featureset-from-data-expression/m-p/1396011#M9271</guid>
      <dc:creator>MFazio</dc:creator>
      <dc:date>2024-03-14T16:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Error returning FeatureSet from data expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/error-returning-featureset-from-data-expression/m-p/1396023#M9272</link>
      <description>&lt;P&gt;So, to confirm: you're able to see the data in the console message, but it's the final &lt;STRONG&gt;FeatureSet&lt;/STRONG&gt; command that's failing?&lt;/P&gt;&lt;P&gt;I notice you've got nested loops and filters. This is going to result in a lot of individual calls to the server. You might try throwing everything into &lt;A href="https://codeberg.org/kendall-county-gis/arcade-expressions/src/branch/main/memorize.md" target="_blank"&gt;a custom "memorize" function&lt;/A&gt; to speed things up a bit.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 16:17:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/error-returning-featureset-from-data-expression/m-p/1396023#M9272</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-03-14T16:17:31Z</dc:date>
    </item>
  </channel>
</rss>

