I hope someone can help. I'm learning Arcade and have been struggling with this one for a bit now.
ArcGIS Enterprise 11.3 Portal Dashboard app.
I have two polygon layers loaded into a Web Map, both are hosted feature services. Fuel Load and Compartments. They both have a LID field.
The web map is added to the dashboard. I want to create a Serial Chart in the Dashboard using a Data Expression, that joins these two layers on LID and returns fields from both that I can use.
I don't get any errors but once I click DONE, it says 'Unable to Execute Arcade Script.'
Any help will be appreciated.
// Replace with your actual Portal item IDs
var fuelItemID = "b1234567897c44428d5756461df44455"; // Clan Fuel Lod
var compItemID = "e9876543215143799cc23fe3018jhr89"; // Clan Compartments
// Access both layers
var compLayer = FeatureSetByPortalItem(Portal("https://gis.my.org.com/portal"), compItemID, 0, ["LID", "Plantation", "District", "SuperDistrict"]); // Array to store joined features
var joinedFeatures = [];
// Join loop
for (var fuel in fuelLayer) {
var lid = fuel["LID"];
var match = First(Filter(compLayer, "LID = @lid"));
if (!IsEmpty(match)) {
var attributes = {
COMPNO: fuel["COMPNO"],
FUELLOADS: fuel["FUELLOADS"],
Plantation: match["Plantation"],
District: match["District"],
SuperDistrict: match["SuperDistrict"]
};
Push(joinedFeatures, {
attributes: attributes
});
}
}
// Define output FeatureSet schema
var fields = [
{ name: "COMPNO", type: "esriFieldTypeString" },
{ name: "FUELLOADS", type: "esriFieldTypeInteger" },
{ name: "Plantation", type: "esriFieldTypeString" },
{ name: "District", type: "esriFieldTypeString" },
{ name: "SuperDistrict", type: "esriFieldTypeString" }
];
// Return a proper FeatureSet
return FeatureSet({
fields: fields,
geometryType: "",
features: joinedFeatures
});