i am trying to get all content features and put their GlobalID inside new array and use this array later to filter the table or the feature class containing this features.
var contentRows = FeatureSetByAssociation($feature, "content");
var globalIds = [];
var i = 0;
for (var v in contentRows) {
globalIds[i++] =v.globalId
}
var asset_Array=[27,26]
var deviceClass = FeatureSetByName($datastore, "CommunicationsJunctionObject");
var devicesRows = Filter(deviceClass, "globalid in @globalIds");
return{'errorMessage':count(devicesRows)}
Error Message
Solved! Go to Solution.
I believe ArcGIS uses default values when it verifies Arcade expressions. That means that it often doesn't find anything with functions like FeaturesetByRelationshipName() and Filter() adn returns empty featuresets.
In your case, it returned an empty fs with FeaturesetByAssociation(), so your globalIDs array is empty, which leads to your query being "GlobalID IN ()" which is invalid.
Try guarding against empty featuresets:
var contentRows = FeatureSetByAssociation($feature, "content");
var globalIds = [];
var i = 0;
for (var v in contentRows) {
globalIds[i++] =v.globalId
}
var deviceCount = 0 // set a defaul value
if(i > 0) { // only enter this block if contentRows is not empty
var asset_Array=[27,26]
var deviceClass = FeatureSetByName($datastore, "CommunicationsJunctionObject");
var devicesRows = Filter(deviceClass, "globalid in @globalIds");
deviceCount = Count(deviceRows) // overwrite the default value
}
return{'errorMessage':deviceCount}
I believe ArcGIS uses default values when it verifies Arcade expressions. That means that it often doesn't find anything with functions like FeaturesetByRelationshipName() and Filter() adn returns empty featuresets.
In your case, it returned an empty fs with FeaturesetByAssociation(), so your globalIDs array is empty, which leads to your query being "GlobalID IN ()" which is invalid.
Try guarding against empty featuresets:
var contentRows = FeatureSetByAssociation($feature, "content");
var globalIds = [];
var i = 0;
for (var v in contentRows) {
globalIds[i++] =v.globalId
}
var deviceCount = 0 // set a defaul value
if(i > 0) { // only enter this block if contentRows is not empty
var asset_Array=[27,26]
var deviceClass = FeatureSetByName($datastore, "CommunicationsJunctionObject");
var devicesRows = Filter(deviceClass, "globalid in @globalIds");
deviceCount = Count(deviceRows) // overwrite the default value
}
return{'errorMessage':deviceCount}
It works just fine, Thanks