Hi,
I'm trying to create Arcade Expression, that will join the feature layer and a feature table for different widgets in Operations Dashboard, but my expression cannot load the data, please help me, as I suspect that something was not provided for in the code of this expression.
var portal = Portal("https://www.arcgis.com/");
var polyfs = FeatureSetByPortalItem(portal,"2c70f00e262a4488b266595720312617",0,["*"],true);
var tablefs = FeatureSetByPortalItem(portal,"227503e1ba6848baa7227b6311c04802",0,["*"],false);
var joinedDict = {
fields: [
{ name: "StreetID", type: "esriFieldTypeInteger" },
{ name: "Name", type: "esriFieldTypeString" },
{ name: "Depth", type: "esriFieldTypeFloat" },
],
'geometryType': '',
'features':[]};
var i = 0;
for (var t in tablefs) {
var tableID = t["StreetID"]
for (var p in Filter(polyfs, "StreetID = "+tableID)){
joinedDict.features[i] = {
attributes: {
StreetID: tableID,
Name: p["Address"],
Depth: t["Depth"],
}
}
}
i++
}
return FeatureSet(Text(joinedDict));
Thank you,
Roman
Solved! Go to Solution.
Ah, I see it now. You are trying to cast the Depth as a "float", which isn't in the list of field types you can use (even though it is a valid data type in other contexts).
Change that to 'esriFieldTypeDouble' and it evaluates just fine:
I would guess it has something to do with that Filter statement, but since the layers aren't shared publicly, it's hard to say for sure. Usually when referencing a variable in your expression string, you should put it in the string itself in the format @variableName. Try this to see if the output changes.
var i = 0;
for (var t in tablefs) {
var tableID = t["StreetID"]
var filt_poly = Filter(polyfs, "StreetID = @tableID")
for (var p in filt_poly){
joinedDict.features[i] = {
attributes:
StreetID: tableID
Name: p["Address"],
Depth: t["Depth"],
}
}
}
i++
}
Hi Josh,
Thanks for your answer, I applied your recomendations, but it not working. When I click Test button, I don't see error:
But after click Done button I see error in the expression:
I shared this services as public for everyone,
Thank you,
Roman
Ah, I see it now. You are trying to cast the Depth as a "float", which isn't in the list of field types you can use (even though it is a valid data type in other contexts).
Change that to 'esriFieldTypeDouble' and it evaluates just fine:
Josh, thank you very much, it is working
Roman