Hi, I am trying to combine the attributes from two layers hosted in the ArcGIS server with following code in Arcade Data Expression . In both layers, the fields on which the join will based is of the same data type i.e. String. The expression is returning following error.
// Create empty features array and feat object
var features = [];
var feat;
for (var t in CS) {
var tableID = t["ID"]
for (var p in Filter(DTS, "FEEDERID = "+tableID)){
feat = {
attributes: {
Name: t["Name"],
}
}
Push(features, feat)
}
}
var joinedDict = {
fields: [
{ name: "Name", type: "esriFieldTypeString" },
],
'geometryType': '',
'features':features
};
// Return dictionary cast as a feature set
return FeatureSet(joinedDict);
Error Snapshot :
The field type is string, so your SQL filter expression should look for string values. You have to enclose your tableID with single quotes:
for (var p in Filter(DTS, "FEEDERID = '"+tableID+"'")){
//...
}
Better yet, let Arcade handle the types:
for (var p in Filter(DTS, "FEEDERID = @tableID")){
//...
}
Hi Johannes,
Thanks for your suggestion, now a different error is shown as below:
Execution Error:Invalid Parameter
FeatureSet() needs a json string, not a dictionary. Try this:
return FeatureSet(Text(joinedDict));