I have a data expression that I have created using this 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: 'Test execution error: Unknown Error. Verify test data.'
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));
So, to confirm: you're able to see the data in the console message, but it's the final FeatureSet command that's failing?
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 a custom "memorize" function to speed things up a bit.