Select to view content in your preferred language

Data Expression in Dashboard returning errors after year of working

233
5
Jump to solution
a week ago
Labels (1)
VigilMelissaVigil
New Contributor

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))

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

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";

 

 

 

View solution in original post

5 Replies
AustinAverill
Frequent Contributor

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. 

CodyPatterson
MVP Regular Contributor

Hey @VigilMelissaVigil 

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

KenBuja
MVP Esteemed Contributor

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";

 

 

 

VigilMelissaVigil
New Contributor

That worked. Thank you so much. Sorry I am very new to Arcade.

0 Kudos
PaulSweeney3
Frequent Contributor

Yes agree with @KenBuja  i often see this issue with the filter function most likely some new or unexpected data has been added . @KenBuja great tip on the variable substitution

0 Kudos