Select to view content in your preferred language

Update feature attribute in other layer using Arcade

131
0
08-22-2024 06:08 AM
Ashok
by
Occasional Contributor

 

Dear Community,

 

I am working on Field map application using ArcGIS Enterprise version 11.2.

I am having a requirement like I would like to update  Assignment layer feature's attribute value(For example Status ) when I edit and submit the Survey layer feature in the same Field map using Arcade expression. 

I tried with below code, but it is not working. Please do needful.

var portalUrl = 'https://xyz.com/portal/';
 
// Create a FeatureSet from the server layer using the provided URL
var serverLayer = FeatureSetByPortalItem(Portal(portalUrl), '1234abcdxxxxx', 0, ['structure_status','status', 'location'], false);
 
// Get the current feature's OBJECTID
var currentFeature = $feature;
var currentObjectID = currentFeature['OBJECTID'];
 
// Initialize a variable to store the assigned date
var assignedDate = null;
 
// Loop through all features in the server layer
for (var feature1 in serverLayer) {
    // Get the location of the current feature
    var location = feature1['location'];
 
    // Split the location at the colon and get the last part (OBJECTID)
    var locationParts = Split(location, ':');
    var locationObjectID = Trim(locationParts[-1]);  // -1 index gets the last part in Arcade
 
    // Compare the location's OBJECTID with the current feature's OBJECTID
    if (locationObjectID == currentObjectID) {
        // If there's a match, store the assigned date and exit the loop
        feature1['structure_status'] = 3;
       
        break;
    }
}
 
// Return the assigned date if found, otherwise return null
//return locationObjectID;

 

 

 

Thanks,

Ashok

 

 

0 Kudos
0 Replies