<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Update feature attribute in other layer using Arcade in ArcGIS Field Maps Questions</title>
    <link>https://community.esri.com/t5/arcgis-field-maps-questions/update-feature-attribute-in-other-layer-using/m-p/1525694#M9368</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dear Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on Field map application using ArcGIS Enterprise version 11.2.&lt;/P&gt;&lt;P&gt;I am having a requirement like I would like to update&amp;nbsp; 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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried with below code, but it is not working. Please do needful.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;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;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ashok&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Aug 2024 13:10:47 GMT</pubDate>
    <dc:creator>Ashok</dc:creator>
    <dc:date>2024-08-22T13:10:47Z</dc:date>
    <item>
      <title>Update feature attribute in other layer using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/update-feature-attribute-in-other-layer-using/m-p/1525694#M9368</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dear Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on Field map application using ArcGIS Enterprise version 11.2.&lt;/P&gt;&lt;P&gt;I am having a requirement like I would like to update&amp;nbsp; 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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried with below code, but it is not working. Please do needful.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;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;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ashok&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 13:10:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/update-feature-attribute-in-other-layer-using/m-p/1525694#M9368</guid>
      <dc:creator>Ashok</dc:creator>
      <dc:date>2024-08-22T13:10:47Z</dc:date>
    </item>
  </channel>
</rss>

