Hi,
I adopted this dashboard that has some arcade expressions written in it and I need to create an update to the script, but the same problem as this topic. I click "test" and it returns the proper result. I click done, but then see a little triangle with an! telling me "Unable to execute Arcade script". Although, I don't have a relationship table to this feature service.
var init_fs = FeatureSetByPortalItem(
Portal('https://arcgis.com'),
'XXXX',
0,
['Borough',
'District',
'label',
// 'WorkComplete',
'SLA',
// 'Approval',
'DateOfWork',
// 'GrassActive',
// 'InCompReason',
// 'Hr48_flag'
],
False);
var mostRecentVisit = Filter(
GroupBy(init_fs,
['Borough',
'District',
'label',
'SLA',
// 'GrassActive',
// 'Approval',
// 'WorkComplete',
// 'InCompReason',
// 'Hr48_flag'
],
{name: 'MaxDate', expression: 'DateOfWork', 'statistic': 'MAX'})
,"DateOfWork is not Null")
;
var novy = {
'fields': [
{'name': 'Borough',
'type': 'esriFieldTypeString'},
{'name':'District',
'type':'esriFieldTypeString'},
{'name':'SiteName',
'type':'esriFieldTypeString'},
{'name':'SLA',
'type':'esriFieldTypeInteger'},
// {'name':'Approval',
// 'type':'esriFieldTypeString'},
{'name':'DateOfWork',
'type':'esriFieldTypeDate'},
// {'name': 'WorkComplete',
// 'type': 'esriFieldTypeString'},
// {'name': 'InCompReason',
// 'type': 'esriFieldTypeString'},
// {'name': 'Hr48_flag',
// 'type': 'esriFieldTypeInteger'},
{'name': 'met_SLA',
'type': 'esriFieldTypeString'}
],
'geometryType': '',
'features': []
}
for (var v in mostRecentVisit) {
var date_cutoff = When(v.SLA == 1, DateAdd(Today(),-7,'days'),
v.SLA == 2, DateAdd(Today(),-14,'days'),
v.SLA == 3, DateAdd(Today(),-21,'days'),
DateAdd(Today(), -28, 'days'));
//bizarre workaround so that date variable doesn't break the feature set: https://community.esri.com/t5/developers-questions/arcade-dictionary-to-featureset/m-p/1048379#M5824
var start = ToLocal(Date(1970, 0, 01, 0, 0, 0, 0));
//use the most recent date variable: MaxDate
var dt = DateDiff(v.MaxDate, start, 'milliseconds');
// This was the old var --> var met_SLA = IIF(dt > date_cutoff, True, False); below is the new var, and now i'm getting this issue
var met_SLA = When(dt > date_cutoff,true, dt > date_cutoff &&
"WorkComplete = 'yes'", True, False);
var new_f = {'attributes':
{'Borough': v.Borough,
'District': v.District,
'SiteName': v.label,
'SLA' : v.SLA,
// 'Approval': v.Approval,
'DateOfWork': dt,
// 'WorkComplete': v.WorkComplete,
// 'InCompReason': v.InCompReason,
// 'Hr48_flag': v.Hr48_flag,
'met_SLA': met_SLA
}
}
Push(novy.features, new_f)
}
//Filter by date threshold
return FeatureSet(Text(novy)) ;
Any suggestions?