<?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 Re: Update ID field using another feature class in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023481#M43047</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/38008"&gt;@SarahHartholt&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;You are welcome.&lt;/P&gt;&lt;P&gt;To take it a step further and include the validation to see if the main is contained by a buffer of the roads, have a look at this example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Function IsContainedByRoads(watermain, roads) {
    var bufs = [];
    // create list of selected roads buffer
    for (var road in roads) {
        var buf = Buffer(road, 10, 'meter');
        bufs[Count(bufs)] = buf;
    }
    // union the road buffers
    var buftot = Union(bufs);
    // validate if watermain is contained by total buffer
    return Contains(buftot, watermain);
}

//On Insert or Update populate Coordinate ID 
var fsRoads = FeatureSetByName($datastore, "Centreline_Assets", ["Coordinated_ID"], True);
var watermain = $feature;
var watermainbuf = Buffer(watermain, 10, 'meter');
var roads = Intersects(fsRoads, watermainbuf);
var cnt = Count(roads);

// check different situations
if (cnt == 0) {
    // there are no roads found
    return null;
} else if (cnt == 1) {
    // there is a one road, validate if the main is contained by the roads buffer
    if (IsContainedByRoads(watermain, roads)) {
        return First(roads)["Coordinated_ID"]; // create the ID using NextSequenceValue
    } else {
        // what to return when the main is not contained?
        return null;
    }
} else {
    // there are multiple roads found, validate if the main is contained by the roads
    if (IsContainedByRoads(watermain, roads)) {
        //find the longest segment
        var maxsegmentlength = 0;
        var CoordID = null;
        for (var road in roads) {
            var segment = Intersection(road, watermainbuf);
            var segmentlength = Length(segment, 'meter');
            if (segmentlength &amp;gt; maxsegmentlength) {
                CoordID = road["Coordinated_ID"];
                maxsegmentlength = segmentlength;
            }
        }
        return CoordID; // create the ID using NextSequenceValue
    } else {
        // what to return when the main is not contained?
        return null;
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Feb 2021 16:44:46 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2021-02-04T16:44:46Z</dc:date>
    <item>
      <title>Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023150#M43026</link>
      <description>&lt;P&gt;I am fairly new to Arcade and am trying to update the CoordinatedID field in my WaterMain layer using an attribute rule with the help of some code found here:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/attribute-rule-script-expression.htm" target="_blank" rel="noopener"&gt;Attribute rule script expression examples—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;What I would like to do it grab the CoordinatedID field from my Roads (Centreline_Assets) layer and use it to populate the CoordinatedID field in my WaterMains (WaterMains_Assets) layer. They layers don't line up exactly so I am trying to buffer the road by 10m and populate the Coordinated field based on an intersection between the buffer and the WaterMains layer. Here's what I have so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;//On Insert or Update populate Coordinate ID 
var fcRoad=FeatureSetByName($datastore, "Centreline_Assets",["Coordinated_ID"])
var fcWaterMain=FeatureSetByName($datastore,"WaterMain_Assets_SplitLine",["Coordinated_ID"])
Var RoadIntersect = Intersects(Buffer(fcRoad,10,'meter'),fcWaterMain)
var AddList = []
var counter = 0
var noCID = Count(RoadIntersect)
if (noCID&amp;gt;0){
    for (var Road in RoadIntersect){
        AddList[counter]={
            'Coordinated_ID':Centreline_Assets.CoordinatedID,
            'attributes':{
                'add_CoordinateID':$feature.Coordinated_ID
            }
        }
        counter++
    }
    return {
        'result': noCID + ' Coordinated ID found',
        'edit': [{
            'className':'Centreline_Assets',
            'updates': AddList
        }]
    }
}else{
    return 'No Coordinated ID'
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I keep getting the following error:&lt;/P&gt;&lt;P&gt;Invalid expression. Error on line 4. Geometry type null expected.&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 20:54:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023150#M43026</guid>
      <dc:creator>SarahHartholt</dc:creator>
      <dc:date>2021-02-03T20:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023211#M43027</link>
      <description>&lt;P&gt;Did you mean to spell Centerline this way?&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;Centreline&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 21:30:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023211#M43027</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-02-03T21:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023228#M43028</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/38008"&gt;@SarahHartholt&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The error is pointing to line 4 and it is because you can't buffer a featureset, you can only buffer and single feature.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 22:32:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023228#M43028</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-02-03T22:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023253#M43029</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;. Is there any way for me to run my arcade expressions through a debugger? I've started using the Arcade playground but I haven't figured out a way to bring my features and attributes into it for testing. Please let me know if there are any useful articles that I could read on the topic.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 00:30:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023253#M43029</guid>
      <dc:creator>SarahHartholt</dc:creator>
      <dc:date>2021-02-04T00:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023356#M43032</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/38008"&gt;@SarahHartholt&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I agree that debugging attribute rules is a bit tricky. However, you could use part of the expression in a pop-up to validate the result. You cannot use a return type that writes to a featureclass, but at least you will be able to see if the logic that occurs before returning the result is working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the playground is great to check functions and logic, but you won't have access to your data and the sample data provided is very limited (2 polygon layers).&lt;/P&gt;&lt;P&gt;Related to the specific problem you are trying to tackle, there might be some additional complications since&amp;nbsp;I suppose a waterline could intersect with multiple road buffers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you create an attribute rule on your waterlines, you will want to read the current waterline feature and buffer it and intersect the buffer with the road features. Then (maybe) you would have to check the length of the road segments inside the waterline buffer, to see which&amp;nbsp;Coordinated_ID you should take.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 13:11:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023356#M43032</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-02-04T13:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023363#M43034</link>
      <description>&lt;P&gt;Yes there are some other issues that I need to consider. Like you said, the waterlines will intersect with multiple road buffers (blue lines are waterlines, black lines are roads &amp;amp; 10m buffer is grey):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SarahHartholt_0-1612445039662.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/5286iC54AD58606484069/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SarahHartholt_0-1612445039662.png" alt="SarahHartholt_0-1612445039662.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I was hoping that I could automate some of the processes I want to achieve using Arcade rather than having to run geoprocessing tools when I add data to my layers but I think I'm in over my head on this one.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 13:28:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023363#M43034</guid>
      <dc:creator>SarahHartholt</dc:creator>
      <dc:date>2021-02-04T13:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023369#M43035</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/38008"&gt;@SarahHartholt&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I think this is something that can be done. You can intersect the waterline buffer with the roads and evaluate the length of the road inside the buffer and take the Coordinate_ID of the longest road segment.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do have a couple of questions:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Do you want to do this as a Batch or as an immediate calculation triggered by an edit?&lt;/LI&gt;&lt;LI&gt;How will you handle waterlines that are not contained by the roadbuffer in your screenshot? Should these get the Coordinate_ID of the road it crosses or no&amp;nbsp;Coordinate_ID?&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Thu, 04 Feb 2021 13:41:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023369#M43035</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-02-04T13:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023385#M43036</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp; don't think I know arcade well enough to accomplish this myself.&lt;/P&gt;&lt;P&gt;I was hoping I could do this as an immediate calculation. Right now when a road segment is added to my roads layer, I have an update rule that populates the Coordinated_ID field with the Next Sequence Value. Once the road layer is populated, I think I need to split the waterlines at vertices - the idea being that the U shaped segments&amp;nbsp;will be separated into smaller pieces that line up with the roads more closely, making it easier to assign the correct Coordinated_ID. I was hoping that splitting the water lines would trigger the expression to grab the Coordinated_ID from the roads feature.&lt;/P&gt;&lt;P&gt;Waterlines that are not contained in the road buffer will need to be manually inspected and would likely be assigned a separate Coordinated_ID that is not associated with a road segment.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 14:04:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023385#M43036</guid>
      <dc:creator>SarahHartholt</dc:creator>
      <dc:date>2021-02-04T14:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023386#M43037</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/38008"&gt;@SarahHartholt&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Since you are editing the same layer of the feature the return type does not have to be the object including the name of the featureclass. Have a look at the example below (without using NextSequenceValue):&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//On Insert or Update populate Coordinate ID 
var fsRoads = FeatureSetByName($datastore, "Centreline_Assets",["Coordinated_ID"], True);
var watermain = $feature;
var watermainbuf = Buffer(watermain, 10, 'meter');
var roads = Intersects(fsRoads, watermainbuf);
var cnt = Count(RoadIntersect);

// check different situations
if (cnt == 0) {
    // there are no roads found
    return null;
} else if (cnt == 1) {
    // there is a one road, return the Coordinate_ID
    return First(roads)["Coordinated_ID"];
} else {
    // there are multiple roads found, find the longest segment
    var maxsegmentlength = 0;
    var CoordID = null;
    for (var road in roads) {
        var segment = Intersection(road, watermainbuf);
        var segmentlength = Length(segment, 'meter');
        if (segmentlength &amp;gt; maxsegmentlength) {
            CoordID = road["Coordinated_ID"];
            maxsegmentlength = segmentlength;
        }
    }
    return CoordID;
}
&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 04 Feb 2021 14:10:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023386#M43037</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-02-04T14:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023391#M43038</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;, looks great and I find the comments very helpful! I am getting an error on line 6 though - object not found &lt;EM&gt;roadintersect&lt;/EM&gt;. When I change the variable to&amp;nbsp;&lt;EM&gt;roads &lt;/EM&gt;I get a&amp;nbsp;general function failure. Not sure what's going on there.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 14:27:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023391#M43038</guid>
      <dc:creator>SarahHartholt</dc:creator>
      <dc:date>2021-02-04T14:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023394#M43039</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/38008"&gt;@SarahHartholt&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Good catch, it should indeed be "roads". I wonder why the general function failure is happening. The general function failure closed your ArcGIS Pro session? What version are you using? Where are the centerlines and water mains stored (they should be in the same $datastore)?&lt;/P&gt;&lt;P&gt;Would it be possible to share a small piece of data to do some testing?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 14:38:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023394#M43039</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-02-04T14:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023406#M43040</link>
      <description>&lt;P&gt;ArcPro stays open. I get the error when verifying the code in the Expression Builder within the Attribute Rule window. I'm using ArcPro 2.6.2&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both feature classes are stored in the default geodatabase that is automatically created with the ArcPro project.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SarahHartholt_0-1612450099958.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/5294i9018384CA90E23FC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SarahHartholt_0-1612450099958.png" alt="SarahHartholt_0-1612450099958.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 14:48:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023406#M43040</guid>
      <dc:creator>SarahHartholt</dc:creator>
      <dc:date>2021-02-04T14:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023426#M43041</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/38008"&gt;@SarahHartholt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would recommend you to create an expression in the pop-up of the waterline layer and test the expression divided into parts. First until determining the count and return that count and then the other parts.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 15:23:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023426#M43041</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-02-04T15:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023458#M43043</link>
      <description>&lt;P&gt;I closed the document, re opened it and now the expression that you wrote up seems to work. I think all I need to do now is figure out how to assign global id's to my water main features for the expression to be valid&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 16:10:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023458#M43043</guid>
      <dc:creator>SarahHartholt</dc:creator>
      <dc:date>2021-02-04T16:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023463#M43045</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/38008"&gt;@SarahHartholt&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just go to your featureclass in the catalog window, right click, choose Manage and you will see the option Add GlobalID's&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="XanderBakker_0-1612455560652.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/5306iBDFC91E6614D6CAF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="XanderBakker_0-1612455560652.png" alt="XanderBakker_0-1612455560652.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 16:19:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023463#M43045</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-02-04T16:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023465#M43046</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 16:21:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023465#M43046</guid>
      <dc:creator>SarahHartholt</dc:creator>
      <dc:date>2021-02-04T16:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Update ID field using another feature class</title>
      <link>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023481#M43047</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/38008"&gt;@SarahHartholt&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;You are welcome.&lt;/P&gt;&lt;P&gt;To take it a step further and include the validation to see if the main is contained by a buffer of the roads, have a look at this example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Function IsContainedByRoads(watermain, roads) {
    var bufs = [];
    // create list of selected roads buffer
    for (var road in roads) {
        var buf = Buffer(road, 10, 'meter');
        bufs[Count(bufs)] = buf;
    }
    // union the road buffers
    var buftot = Union(bufs);
    // validate if watermain is contained by total buffer
    return Contains(buftot, watermain);
}

//On Insert or Update populate Coordinate ID 
var fsRoads = FeatureSetByName($datastore, "Centreline_Assets", ["Coordinated_ID"], True);
var watermain = $feature;
var watermainbuf = Buffer(watermain, 10, 'meter');
var roads = Intersects(fsRoads, watermainbuf);
var cnt = Count(roads);

// check different situations
if (cnt == 0) {
    // there are no roads found
    return null;
} else if (cnt == 1) {
    // there is a one road, validate if the main is contained by the roads buffer
    if (IsContainedByRoads(watermain, roads)) {
        return First(roads)["Coordinated_ID"]; // create the ID using NextSequenceValue
    } else {
        // what to return when the main is not contained?
        return null;
    }
} else {
    // there are multiple roads found, validate if the main is contained by the roads
    if (IsContainedByRoads(watermain, roads)) {
        //find the longest segment
        var maxsegmentlength = 0;
        var CoordID = null;
        for (var road in roads) {
            var segment = Intersection(road, watermainbuf);
            var segmentlength = Length(segment, 'meter');
            if (segmentlength &amp;gt; maxsegmentlength) {
                CoordID = road["Coordinated_ID"];
                maxsegmentlength = segmentlength;
            }
        }
        return CoordID; // create the ID using NextSequenceValue
    } else {
        // what to return when the main is not contained?
        return null;
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 16:44:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/update-id-field-using-another-feature-class/m-p/1023481#M43047</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-02-04T16:44:46Z</dc:date>
    </item>
  </channel>
</rss>

