Select to view content in your preferred language

How to move related feature to a new parent feature in Field Maps and update globalid upon relocation

758
10
Jump to solution
04-19-2024 04:01 PM
Teresa_Blader
Frequent Contributor

I deployed the Signs Inventory ArcGIS Solution. One scenario coming up: moving a sign from one pole on one side of the street to a different pole on the other side of the street without retiring/creating a new sign id. I store the Pole ID and the Pole GlobalID in the Signs layer. The globalids are the keys between Signs and Poles.

I want Pole ID and the Pole GlobalID to update when I move a sign to a new post in Field Maps/Smart Form online. It currently does not.

The related records on Signs (Sign Maintenance table) also fetches Signs: sign ID, pole ID, sign global ID, pole global ID, and latitude/longitude each time a record is added - to retain the move history over the years (hypothetically).

How might I write Arcade to overwrite the pole's globalID in Signs layer with it's new related pole globalID?

My first thought was doing a "buffer/nearest" pole calculated expression, but it seems once the pole globalid field is populated in Signs upon creation - it is not editable and the calculated expression is ignored.

"Editing is disabled in the field settings". Is this a setting I can modify in the REST API or JSON using ArcGIS Assistant?

Teresa_Blader_2-1713566203683.png

Teresa_Blader_0-1713565902094.png

Teresa_Blader_1-1713565922620.png

Expression to fetch Pole ID (assetid) into Signs layer for assetID_pole

var poles = FeatureSetByRelationshipName($feature, 'Poles',['assetid'],true)
// Get the feature set for the poles

// Get the first poles (should only be one)
var pole = First(poles)

// If there was a pole, return the assetid of it,
// Otherwise, return null
if (!IsEmpty(pole)) {
    return pole['assetid']
} else {
    return null
}

 

At some point I tried implementing a calculated expression in the form (like what I did for location description below, getting the nearest county road). For that it was told to fetch the nearest pole globalid within a 10 ft buffer of the sign, but didn't do anything so I removed it. 

// If feature doesn't have geometry return null
if (IsEmpty(Geometry($feature))) { return null }

// Get the roads layer
var agol = 'https://www.arcgis.com/'
var roads = FeatureSetByPortalItem(Portal(agol), '7abbff41fefe4bfa88cec88256022c33',2,['RD_SYMBOL','RD_SYSTEM'],true)
var CR_CSAH = "RD_SYMBOL IS NOT NULL AND (RD_SYSTEM ='CR' OR RD_SYSTEM = 'CSAH')"
var rel_roads = Filter(roads, CR_CSAH)

// Buffer the current location and intersect with roads
var bufferedLocation = Buffer($feature, 200, 'feet')
var candidateroads = Intersects(rel_roads, bufferedLocation)

// Calculate the distance between the road and the current location
// Store the feature and distance as a dictionary and push it into an array
var featuresWithDistances = []
for (var f in candidateroads) {
    Push(featuresWithDistances, 
        {
            'distance': Distance($feature, f, 'feet'),
            'feature': f
        }
    )
}

// Sort the candidate roads by distance using a custom function
function sortByDistance(a, b) {
    return a['distance'] - b['distance']
}
var sorted = Sort(featuresWithDistances, sortByDistance)

// Get the closest feature
var closestFeatureWithDistance = First(sorted)

// If there was no feature, return null
if (IsEmpty(closestFeatureWithDistance)) { return null }

// Return the address */
return `${closestFeatureWithDistance['feature']['RD_SYSTEM']} ${closestFeatureWithDistance['feature']['RD_SYMBOL']}`

 

Teresa Blader
Olmsted County GIS Specialist
0 Kudos
10 Replies
Teresa_Blader
Frequent Contributor

Thank you! That seems to be the ticket! Much simpler too 😂

Teresa Blader
Olmsted County GIS Specialist
0 Kudos