This data expression has been working for over a year and all the sudden stopped in the last week.
This data expression is to pull active checks
var fs = FeatureSetByPortalItem(
Portal("https://sjso-e911.maps.arcgis.com"),
"13e8ddb852f94e7c840dbef6612ed728",
1,
[
"nbid2",
"nextrecheckdate",
"Name",
"birthday",
"schoolname1",
"yrddistrict1",
"activecase"
],
false
);
var date_exp = {
name: "Max_Date",
expression: "nextrecheckdate",
statistic: "MAX"
};
var grouped = GroupBy(fs, ["nbid2"], date_exp);
var features = [];
var list = [];
for (var f in grouped) {
var student = f["nbid2"];
var sdate = ToUTC(f["Max_Date"]);
var sdate_local = f["Max_Date"];
var sql = "nextrecheckdate = '" +
sdate +
"'AND nbid2 = '" +
student +
"'";
Push(features, sql);
}
var joinedDict = {
fields: [
{ name: "nextrecheckdate", type: "esriFieldTypeDate"},
{ name: "nbid2", type: "esriFieldTypeString"},
{ name: "Name", type: "esriFieldTypeString"},
{ name: "birthday", type: "esriFieldTypeDate"},
{ name: "schoolname1", type: "esriFieldTypeString"},
{ name: "yrddistrict1", type: "esriFieldTypeString"},
{ name: "activecase", type: "esriFieldTypeString"}
],
geometryType: "",
features: []
};
//return features
for (var p in features) {
var n = features[p];
var fil = Filter(fs, n);
for (var h in fil) {
Push(
joinedDict["features"],
{
attributes:
{
nextrecheckdate: h["nextrecheckdate"],
nbid2: h["nbid2"],
Name: h["Name"],
birthday: h["birthday"],
schoolname1: h["schoolname1"],
yrddistrict1: h["yrddistrict1"],
activecase: h["activecase"],
}
}
);
}
}
return FeatureSet(Text(joinedDict))
Solved! Go to Solution.
That error is usually associated with a problem in the Filter function sql statement. Check your fields and if those field names and values are valid.
You can make the sql statement easier to read using variable substitution (see the documentation). You don't have to worry about quotes using this syntax
var student = f["nbid2"];
var sdate = ToUTC(f["Max_Date"]);
var sdate_local = f["Max_Date"];
var sql = "nextrecheckdate = @sdate AND nbid2 = @student";
Attempting to find issues in the Arcade GUI can be infuriating. You are likely going to need to add console statements inside each of your loops, and after each function to help determine where the scripts is breaking.
I agree with Austin on the console statements, you may also find some use in cutting down your program from the bottom up, start attempting to run/verify it's working with the variable assignments and Portal attach section. I think it could be your SQL statement improperly recognizing a keyword or something similar, I would try commenting that out or running a known working one and trying again!
Cody
That error is usually associated with a problem in the Filter function sql statement. Check your fields and if those field names and values are valid.
You can make the sql statement easier to read using variable substitution (see the documentation). You don't have to worry about quotes using this syntax
var student = f["nbid2"];
var sdate = ToUTC(f["Max_Date"]);
var sdate_local = f["Max_Date"];
var sql = "nextrecheckdate = @sdate AND nbid2 = @student";
That worked. Thank you so much. Sorry I am very new to Arcade.