Select to view content in your preferred language

Dashboard Edit - "failed to calculate value"

333
4
03-12-2025 08:04 AM
DerekBernard
Frequent Contributor

I created a web map and setup a form with a calculated field (grab property address from nearest parcel).  It works in the web map and works in the Experience Builder App I built.  But in the Dashboard I get the error "Failed to calculate value."

FORM Code:
var searchDist = 100;
    var addresses = Intersects(FeatureSetByName($map, "City Parcels"), Buffer( $feature, searchDist, "feet"));
    var nearestaddress;
    var min_dist = 150;
    for (var f in addresses){
        var addressDist = Round(Distance(f, $feature, "feet"),2);
        if (addressDist < min_dist) {
            nearestaddress = f.PROP_ADD1;
            min_dist = addressDist;
        }
    }

    return nearestaddress;

 

 

I guess it might be a little more complicated because this field is only editable if another field is switched on.

 

Any ideas?

0 Kudos
4 Replies
CodyPatterson
MVP Regular Contributor

Hey @DerekBernard 

I'm curious if it would be possible to use something instead of FeatureSetByName, something like FeatureSetByPortalItem perhaps, this may be able to get this sorted as the variables may not be able to be accessed. Here is the documentation here: https://developers.arcgis.com/arcade/function-reference/portal_functions/#featuresetbyportalitem

Cody

0 Kudos
DerekBernard
Frequent Contributor

I tried changing the line and it doesn't work.  I might not be using the function correctly.

 

    var addresses = Intersects(FeatureSetByPortalItem(Portal('https://arcgis.co.beltrami.mn.us/'),'9c473ed759734b9a9a5799a8c20f9e39',0,['*'],true), Buffer( $feature, searchDist, "feet"));
0 Kudos
CodyPatterson
MVP Regular Contributor

Hey @DerekBernard 

Pretty close! This is more what I had in mind here:

var searchDist = 100;
var portal = Portal('https://arcgis.co.beltrami.mn.us/');
var parcels = FeatureSetByPortalItem(
    portal,
    '9c473ed759734b9a9a5799a8c20f9e39',
    0,
    ['PROP_ADD1'],
    false
);

var addresses = Intersects(parcels, Buffer($feature, searchDist, "feet"));
var nearestaddress;
var min_dist = 150;

for (var f in addresses) {
    var addressDist = Round(Distance(f, $feature, "feet"), 2);
    if (addressDist < min_dist) {
        nearestaddress = f.PROP_ADD1;
        min_dist = addressDist;
    }
}

return nearestaddress;

Give this a shot and let me know if it's up and going!

Cody

0 Kudos
DerekBernard
Frequent Contributor

I can't get this to work in just the web map even.  Maybe I have my portal or item id wrong.  Do you know how to confirm those?

 

DerekBernard_0-1741804253870.png

 

0 Kudos