Here is my code to sum the length field times the width field to get the total area for line features.
The first line of your script doesn't return a FeatureSet, but rather a dictionary. You have to use the layer property to get the features from $dataSource.
var fs = $dataSources["dataSource_1-19d7400ea8f-layer-20"].layer;
var total = 0;
for (var f in fs) {
var len_in_inches = f.Shape.STLength() * 12;
var width_in_inches = Number(f.Width_Inches, 0);
total += width_in_inches * len_in_inches;
}
return total;
Thanks for the response. I am getting a new error with the f.Shape callout.
"Key not found - Shape."
Not sure why, but I did notice your code only has the STLength() in red and not the entire name.
My field is the esri feature class field Shape.STLength() field.
Thanks in advance for any additional assistance.
I use the JavaScript language selection in the code sample window for Arcade code, which highlights code in a different way than the language that you selected.
When working with a normal FeatureSet, you should be able to return the length of a feature using "f.Shape_Leng". If that doesn't work with your feature, I would suggest using Console function to examine the schema and its available fields.
console(Schema(fs).fields)