Select to view content in your preferred language

Arcade expression to auto populate attributes and include the indoors floor picker on polygon selection

590
1
3 weeks ago
schulte_a
New Contributor

I have ArcIndoors and all my floor data (using the Indoors schema). I want to spin up web maps using smart forms, to where when a person places say a point in the Fire Extinguisher layer, it will auto populate in the extinguisher attributes for the LEVEL_ID, Building Number/Name, Room Number, grabbing said attributes from the Facilities/Levels/Units Indoor layers. This is the Arcade expression I used, but it seemingly isn't taking into account the floor picker. Any suggestions?

function getContainingID(Levels, LEVEL_ID) {
var fs = FeatureSetByName($map, Levels, [LEVEL_ID, "SHAPE@"]);
   var hit = First(
   Intersects(fs, Geometry($feature))
);
   return IIF(
   IsEmpty(hit),
   null,
   hit[LEVEL_ID]
);
}

1 Reply
czahn2
by
Emerging Contributor

My team is struggling with the same issue right now. We have found this page of documentation for the Experience Builder Floor Filter Widget: Floor Filter widget—ArcGIS Experience Builder | Documentation

If you scroll down to near the bottom there is an Arcade script:

if ($editcontext.editType == "INSERT") {

var levelsLayer = FeatureSetByName($map, "Levels", ["*"], true);

var features = Intersects(levelsLayer,$feature);

if (Count(features) > 0) {

var levelId = First(features)["LEVEL_ID"]; return levelId;

    }

} return $feature["LEVEL_ID"];

We have had inconsistent luck with getting this to function correctly. It sometimes errors out with 'Failed to calculate value'. But worth a shot. 

For Field Maps the Arcade is a little different due to how Experience Builder and Field Maps natively support Indoors. We got a script from the Field Maps Team for Unit ID, which could potentially be modified to populate Level ID:

if(IsEmpty(Geometry($feature)))

    return null

else if (IsEmpty($feature.LEVEL_ID)){

    return null   

}

else {

    var filt_floor = $feature.LEVEL_ID

    var result = First(Intersects($feature,Filter(FeatureSetByName($map, 'Units'),'LEVEL_ID = @filt_floor')));

   

    if(IsEmpty(result))

        return null

    else {

        return result.UNIT_ID; 

    }

 

0 Kudos