Currently, I am trying to write an Arcade expression. I have one feature layer that is related to three standalone tables. In this scenario, I am only using the feature layer "Layer" and one of the tables called "status". This feature layer is used in ArcGIS Field Maps where our construction and engineering teams can use and update project development while out in the field. When they update the status field in the status table, I want that to automatically update the status field in the feature layer. These two are related through the GlobalID in the status standalone table and the status_ID (which is a GUID) in the feature layer. Below is my script I created. I have tried so many different ways and I keep getting errors. I created a script in Python that works on Pro but I need something in Arcade that works on Map Viewer so I can configure the pop up. Here is my current Arcade script:
var layer = FeatureSetById('cc74c700497f4e64bbf9ffe157108c90', ["status", "GlobalID"]);
var table = FeatureSetById('cc74c700497f4e64bbf9ffe157108c90', ["status", "status_ID"]);
var updatedStatus = "No Match";
// Loop through features in the layer
for (var feature in layer.features) {
var layerGlobalID = feature.attributes.GlobalID;
// Find corresponding record in the table
var matchingRecords = Filter(table, 'status_ID = @layerGlobalID');
if (Count(matchingRecords) > 0) {
// Get the status value from the matching record
var matchingStatus = First(matchingRecords).attributes.status;
// Update the status field in the layer feature
feature.attributes.status = matchingStatus;
updatedStatus = matchingStatus;
}
}
return updatedStatus