<?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: Calculate From and To Endpoint IDs (from one of several point feature classes) in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1480602#M1482</link>
    <description>&lt;P&gt;To make it a bit easier to get a grasp of, I have modified the code to use a results dictionary without the interim&amp;nbsp;dict.&amp;nbsp; This should make it easier to follow:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;function get_fs(cls_name){
  return Decode(cls_name,
      "sdInlet",FeatureSetByName($datastore, "sdInlet", fields, true),
      "sdOutlet",FeatureSetByName($datastore, "sdOutlet", fields, true),
      "sdCleanOut",FeatureSetByName($datastore, "sdCleanOut", fields, true),
      "sdManhole",FeatureSetByName($datastore, "sdManhole", fields, true),
      "sdDischargePoint",FeatureSetByName($datastore, "sdDischargePoint", fields, true),
      "sdFitting",FeatureSetByName($datastore, "sdFitting", fields, true),
      "sdNetworkStructure",FeatureSetByName($datastore, "sdNetworkStructure", fields, true),
      null)
}
function IsEmptyButBetter(data) {
    if (IsEmpty(data)) return true;
    for (var x in data) return false;
    return true;
}

var fields = ['FacilityID']
var fclist = ['sdManhole','sdInlet','sdOutlet','sdCleanOut', 'sdFitting', 'sdDischargePoint', 'sdNetworkStructure'];
var line_shape = Geometry($feature)
var spRef = line_shape['spatialReference']

// Get the origin and end points of the line
var orig_x = line_shape['paths'][0][0].x
var orig_y = line_shape['paths'][0][0].y
var orig_point = Point({x: orig_x, y: orig_y, spatialReference: spRef})

var end_x = line_shape['paths'][-1][-1].x
var end_y = line_shape['paths'][-1][-1].y
var end_point = Point({x: end_x, y: end_y, spatialReference: spRef})

var umh = 'NA'
var dmh = 'NA'
for (var p in fclist){
    var point_fs = get_fs(fclist[p]);

    //find point intersecting origin
    var origIntx = first(Intersects(orig_point, point_fs));

    //find point intersecting end
    var endIntx = first(Intersects(end_point, point_fs));

    if (!IsEmptyButBetter(origIntx)) {
        var umh = origIntx['FacilityID']
      }


    if (!IsEmptyButBetter(endIntx)) {
        var dmh = endIntx['FacilityID']
      }


}

return {
    "result": {
        "attributes": {
            "UpMH": umh, 
            "DownMH": dmh,
            "FACILITYID": umh + "-" + dmh
        }
    }

}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UpMH, DownMH, and FACILITYID are the column names in the main line FC.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jun 2024 17:35:28 GMT</pubDate>
    <dc:creator>RhettZufelt</dc:creator>
    <dc:date>2024-06-13T17:35:28Z</dc:date>
    <item>
      <title>Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1389710#M1325</link>
      <description>&lt;P&gt;We are still using the Geometric Network in ArcMap, along with Attribute Assistant (AA). We are in the process of exploring a transition to the Trace Network and adopting Attribute Rules in Pro.&lt;/P&gt;&lt;P&gt;We have been using a couple of AA rules to populate a FromID and ToID field with the IDs of the endpoints of a line segment (Sewer Mains) from several possible point feature classes (manholes, nodes, etc).&lt;/P&gt;&lt;P&gt;The &lt;A href="https://solutions.arcgis.com/shared/help/attribute-assistant/documentation/methods-all-methods/#from-junction-field" target="_self"&gt;From Junction Field&amp;nbsp;&lt;/A&gt;&amp;nbsp;(and similar To Junction Field) in AA method made this pretty straightforward, as it would select whatever point feature happened to be at the start or endpoint and grab the associated ID, regardless of what feature class the point happened to be from.&lt;/P&gt;&lt;P&gt;Is there a similar way to use junctions in Arcade to supply From and To IDs to a line from several possible point feature classes? It seems if you're only working with a single point feature class, it would be pretty straightforward (&lt;A href="https://www.youtube.com/watch?v=ueckrlhto0Q" target="_blank"&gt;https://www.youtube.com/watch?v=ueckrlhto0Q&lt;/A&gt;) but for multiple point feature classes, it seems you'd need to create a feature variable for each point feature class, and parse through them like "If there is a manhole point at the From location, grab the ID, Otherwise check if there is a node at the From location and grab the ID" etc.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 20:46:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1389710#M1325</guid>
      <dc:creator>NathanGEOregon</dc:creator>
      <dc:date>2024-03-01T20:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1390270#M1326</link>
      <description>&lt;P&gt;We created a chart of AA methods to AR&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcade-expressions/blob/master/Attribute%20Assistant.md" target="_blank"&gt;https://github.com/Esri/arcade-expressions/blob/master/Attribute%20Assistant.md&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;&lt;A href="https://github.com/Esri/arcade-expressions/blob/master/attribute_rule_calculation/CalcJunctionFields.md" target="_blank"&gt;https://github.com/Esri/arcade-expressions/blob/master/attribute_rule_calculation/CalcJunctionFields.md&lt;/A&gt;&amp;nbsp;rule should work for you.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 11:27:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1390270#M1326</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-03-04T11:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1390714#M1327</link>
      <description>&lt;P&gt;Thanks-&lt;/P&gt;&lt;P&gt;I did see that.&lt;/P&gt;&lt;P&gt;The &lt;A href="https://github.com/Esri/arcade-expressions/blob/master/attribute_rule_calculation/CalcJunctionFields.md" target="_self"&gt;Calculate Attributes by Junction&lt;/A&gt;&amp;nbsp;points to a single feature class (Manholes) as possible Main endpoints. So it appears that if the endpoint could be one of many point feature classes (Manhole, Node, Valve, etc) then you would need to call in each point feature class and loop through them. I was trying to avoid this, as the Arcade code would start to get pretty bloated.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 20:44:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1390714#M1327</guid>
      <dc:creator>NathanGEOregon</dc:creator>
      <dc:date>2024-03-04T20:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1396869#M1358</link>
      <description>&lt;P&gt;This is GREAT!! Thank you, such a helpful resource.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 23:42:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1396869#M1358</guid>
      <dc:creator>VanessaSimps</dc:creator>
      <dc:date>2024-03-15T23:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1396892#M1359</link>
      <description>&lt;P&gt;Possibly related: &lt;A href="https://community.esri.com/t5/arcgis-pro-questions/adding-data-from-two-different-layers-into-another/m-p/1387457" target="_self"&gt;Adding data from two different layers into another layer, stormwater pipes feature IDs&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Mar 2024 03:16:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1396892#M1359</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2024-03-16T03:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1423950#M1438</link>
      <description>&lt;P&gt;Did you end up figuring this out for many points? Example code? Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 17:50:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1423950#M1438</guid>
      <dc:creator>avonmoos</dc:creator>
      <dc:date>2024-05-09T17:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1424163#M1439</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/15530"&gt;@RhettZufelt&lt;/a&gt;&amp;nbsp;any ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 18:20:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1424163#M1439</guid>
      <dc:creator>avonmoos</dc:creator>
      <dc:date>2024-05-09T18:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1424765#M1440</link>
      <description>&lt;P&gt;Have not really looked into this yet as the Trace network is so limited, really has no use case for us at the moment. (at least as long as ArcMap is still going)&lt;/P&gt;&lt;P data-unlink="true"&gt;I have a post &lt;A href="https://community.esri.com/t5/arcgis-pro-questions/adding-data-from-two-different-layers-into-another/m-p/1390528/highlight/true#M79728" target="_self"&gt;here&lt;/A&gt; about&amp;nbsp;doing something similar with Python that could be converted pretty easy with some of the AA rules that&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/188597"&gt;@MikeMillerGIS&lt;/a&gt;&amp;nbsp;posted above.&lt;/P&gt;&lt;P data-unlink="true"&gt;Would have to experiment with the points coming from different dataset and see just how much of a performance hit that causes.&lt;/P&gt;&lt;P data-unlink="true"&gt;I originally set this up for offline use, so my nightly script just combines the manholes and cleanouts (MH's, CO's, Inlets, Outlets, etc. for the Storm layers) into a single point featureclass with the FacilityID and record number.&amp;nbsp; Then, I just have my script check the intersection with this layer at the upstream and downstream ends of the line.&lt;/P&gt;&lt;P data-unlink="true"&gt;Since all I need is the attributes from the points that intersect, this has been working great.&lt;/P&gt;&lt;P data-unlink="true"&gt;Figure when I move to Pro for this, will just modify &lt;A href="https://github.com/Esri/arcade-expressions/blob/master/attribute_rule_calculation/CalcJunctionFields.md" target="_self"&gt;this Arcade code to&lt;/A&gt; intersect against this same 'combined' featureclass as it keeps things simple.&amp;nbsp; Then I may test performance hits comparing this to actually intersecting the start/end points with multiple featureclasses.&lt;/P&gt;&lt;P data-unlink="true"&gt;R_&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 19:48:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1424765#M1440</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-05-09T19:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1458104#M1441</link>
      <description>&lt;P&gt;Thanks for the info Rhett!&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2024 14:03:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1458104#M1441</guid>
      <dc:creator>avonmoos</dc:creator>
      <dc:date>2024-05-13T14:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1476407#M1458</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/612016"&gt;@avonmoos&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the help of&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/188597"&gt;@MikeMillerGIS&lt;/a&gt;&amp;nbsp;I was able to come up with something along these lines.&lt;/P&gt;&lt;P&gt;Set up for my Storm data, the 'endpoints' of a gravity main can be a Manhole, Inlet, Outlet, Cleanout, Discharge Point, Network Structure, or Fitting all of which are in their own featureclass.&lt;/P&gt;&lt;P&gt;Though, have not tested it extensively, should be a good starting point as it is working as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function get_fs(cls_name){
  return Decode(cls_name,
      "sdInlet",FeatureSetByName($datastore, "sdInlet", fields, true),
      "sdOutlet",FeatureSetByName($datastore, "sdOutlet", fields, true),
      "sdCleanOut",FeatureSetByName($datastore, "sdCleanOut", fields, true),
      "sdManhole",FeatureSetByName($datastore, "sdManhole", fields, true),
      "sdDischargePoint",FeatureSetByName($datastore, "sdDischargePoint", fields, true),
      "sdFitting",FeatureSetByName($datastore, "sdFitting", fields, true),
      "sdNetworkStructure",FeatureSetByName($datastore, "sdNetworkStructure", fields, true),
      null)
}
function IsEmptyButBetter(data) {
    if (IsEmpty(data)) return true;
    for (var x in data) return false;
    return true;
}

var fields = ['FacilityID']
var fclist = ['sdManhole','sdInlet','sdOutlet','sdCleanOut', 'sdFitting', 'sdDischargePoint', 'sdNetworkStructure'];
var line_shape = Geometry($feature)
var spRef = line_shape['spatialReference']

// Get the origin and end points of the line
var orig_x = line_shape['paths'][0][0].x
var orig_y = line_shape['paths'][0][0].y
var orig_point = Point({x: orig_x, y: orig_y, spatialReference: spRef})

var end_x = line_shape['paths'][-1][-1].x
var end_y = line_shape['paths'][-1][-1].y
var end_point = Point({x: end_x, y: end_y, spatialReference: spRef})
var attributes = {}

var umh = 'NA'
var dmh = 'NA'
for (var p in fclist){
    var point_fs = get_fs(fclist[p]);

    //find point intersecting origin
    var origIntx = first(Intersects(orig_point, point_fs));

    //find point intersecting end
    var endIntx = first(Intersects(end_point, point_fs));

    if (!IsEmptyButBetter(origIntx)) {
        attributes['UpMH'] = origIntx['FacilityID']
        var umh = attributes['UpMH']
      }


    if (!IsEmptyButBetter(endIntx)) {
        attributes['DownMH'] = endIntx['FacilityID']
        var dmh = attributes['DownMH']
      }

    //add FacilityID to attribute results
    if (!IsEmptyButBetter(attributes)) {
          attributes['FacilityID'] = umh + "-" + dmh
        }
    
    var result = {}
    if (!IsEmptyButBetter(attributes)) {
        result['result'] = {
            'attributes': attributes
        }
    }
}
return result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will find the FacilityID from the upstream and downstream points if exist, populate the UpMH and DownMH fields in the gravity main feature class as well as update the gravity main FacilityID to UpMH-DownMH regardless of which point FC it is in.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 17:35:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1476407#M1458</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-06-13T17:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1476417#M1459</link>
      <description>&lt;P&gt;Thanks for doing the heavy lifting! This looks like what I had in mind!&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 17:31:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1476417#M1459</guid>
      <dc:creator>NathanGEOregon</dc:creator>
      <dc:date>2024-05-21T17:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1476460#M1460</link>
      <description>&lt;P&gt;We are still working on these tools, but take a look at this toolbox.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcade-expressions/blob/master/attribute_assistant/AttributeAssistant.atbx" target="_blank"&gt;https://github.com/Esri/arcade-expressions/blob/master/attribute_assistant/AttributeAssistant.atbx&lt;/A&gt;&lt;/P&gt;&lt;P&gt;We are working on GP tools to create the arcade for you.&amp;nbsp; Lots to do still(hence not really sharing them yet), but they are functioning.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcade-expressions/blob/master/attribute_assistant/readme.md" target="_blank"&gt;https://github.com/Esri/arcade-expressions/blob/master/attribute_assistant/readme.md&lt;/A&gt;&lt;/P&gt;&lt;P&gt;NOTE: The output is a csv that you need to import, so it does not apply the AR&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 18:22:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1476460#M1460</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-05-21T18:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1480556#M1479</link>
      <description>&lt;P&gt;In Attribute Rules I'm only able to update 1 attribute at a time so I made one code for BeginningStructureID and one for EndingStructureID. Here is one of the codes that I came up with based on the example you provided.&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;function get_fs(cls_name) {
  return Decode(cls_name,
      "SewerCleanout", FeatureSetByName($datastore, "COK.SewerCleanout", [], true),
      "SewerLiftStation", FeatureSetByName($datastore, "COK.SewerLiftStation", [], true),
      "SewerManhole", FeatureSetByName($datastore, "COK.SewerManhole", [], true),
      "SewerNode", FeatureSetByName($datastore, "COK.SewerNode", [], true),
      null
  );
}

function IsEmptyButBetter(data) {
  if (IsEmpty(data)) return true;
  for (var x in data) return false;
  return true;
}

// Mapping of feature classes to their FacilityID attribute names
var fc_to_facility_id = {
  'SewerCleanout': 'CleanoutID',
  'SewerLiftStation': 'LiftStationID',
  'SewerManhole': 'ManholeID',
  'SewerNode': 'NodeID'
};

var fclist = ['SewerCleanout',  'SewerLiftStation', 'SewerManhole', 'SewerNode'];
var line_shape = Geometry($feature);
var spRef = line_shape['spatialReference'];

// Get the origin and end points of the line
var orig_x = line_shape['paths'][0][0].x;
var orig_y = line_shape['paths'][0][0].y;
var orig_point = Point({x: orig_x, y: orig_y, spatialReference: spRef});

var attributes = {};

var beginning_structure_id = null;

for (var p in fclist) {
  var fc_name = fclist[p];
  var point_fs = get_fs(fc_name);
  var facility_id_field = fc_to_facility_id[fc_name];

  // Find point intersecting origin
  var origIntx = First(Intersects(orig_point, point_fs));

  if (!IsEmptyButBetter(origIntx)) {
      attributes['BeginningStructureID'] = origIntx[facility_id_field];
      beginning_structure_id = attributes['BeginningStructureID'];
  }
}

Console(beginning_structure_id);
return beginning_structure_id;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 21:24:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1480556#M1479</guid>
      <dc:creator>avonmoos</dc:creator>
      <dc:date>2024-05-29T21:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1480564#M1480</link>
      <description>&lt;P&gt;True if you are just returning a result, but AR allows you to return a dictionary of keywords and update multiple attributes at once.&amp;nbsp; Not real intuitive in my code as I add items to the attributes variable and return that as the 'attributes': keyword in the result dictionary.&lt;/P&gt;&lt;P&gt;Take a &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/attribute-rule-dictionary-keywords.htm#:~:text=You%20can%20return%20result%20as%20a%20dictionary%20to%20update%20multiple%20fields%20of%20the%20feature.%20When%20returning%20result%20as%20a%20dictionary%2C%20the%20target%20field%20in%20the%20attribute%20rule%20is%20optional.%20You%20can%20specify%20any%20field%20to%20update%20in%20the%20dictionary%20using%20the%20keyword%20parameters%20in%20the%20table%20below." target="_self"&gt;look here&lt;/A&gt;, an easier example to see how to return values for multiple attributes from on rule.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 21:55:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1480564#M1480</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-05-29T21:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1480598#M1481</link>
      <description>&lt;P&gt;Wow, I didn't know we could do multiple at once. I'll take a dive into that and play around with it. Thanks again for the info!&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 22:53:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1480598#M1481</guid>
      <dc:creator>avonmoos</dc:creator>
      <dc:date>2024-05-29T22:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1480602#M1482</link>
      <description>&lt;P&gt;To make it a bit easier to get a grasp of, I have modified the code to use a results dictionary without the interim&amp;nbsp;dict.&amp;nbsp; This should make it easier to follow:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;function get_fs(cls_name){
  return Decode(cls_name,
      "sdInlet",FeatureSetByName($datastore, "sdInlet", fields, true),
      "sdOutlet",FeatureSetByName($datastore, "sdOutlet", fields, true),
      "sdCleanOut",FeatureSetByName($datastore, "sdCleanOut", fields, true),
      "sdManhole",FeatureSetByName($datastore, "sdManhole", fields, true),
      "sdDischargePoint",FeatureSetByName($datastore, "sdDischargePoint", fields, true),
      "sdFitting",FeatureSetByName($datastore, "sdFitting", fields, true),
      "sdNetworkStructure",FeatureSetByName($datastore, "sdNetworkStructure", fields, true),
      null)
}
function IsEmptyButBetter(data) {
    if (IsEmpty(data)) return true;
    for (var x in data) return false;
    return true;
}

var fields = ['FacilityID']
var fclist = ['sdManhole','sdInlet','sdOutlet','sdCleanOut', 'sdFitting', 'sdDischargePoint', 'sdNetworkStructure'];
var line_shape = Geometry($feature)
var spRef = line_shape['spatialReference']

// Get the origin and end points of the line
var orig_x = line_shape['paths'][0][0].x
var orig_y = line_shape['paths'][0][0].y
var orig_point = Point({x: orig_x, y: orig_y, spatialReference: spRef})

var end_x = line_shape['paths'][-1][-1].x
var end_y = line_shape['paths'][-1][-1].y
var end_point = Point({x: end_x, y: end_y, spatialReference: spRef})

var umh = 'NA'
var dmh = 'NA'
for (var p in fclist){
    var point_fs = get_fs(fclist[p]);

    //find point intersecting origin
    var origIntx = first(Intersects(orig_point, point_fs));

    //find point intersecting end
    var endIntx = first(Intersects(end_point, point_fs));

    if (!IsEmptyButBetter(origIntx)) {
        var umh = origIntx['FacilityID']
      }


    if (!IsEmptyButBetter(endIntx)) {
        var dmh = endIntx['FacilityID']
      }


}

return {
    "result": {
        "attributes": {
            "UpMH": umh, 
            "DownMH": dmh,
            "FACILITYID": umh + "-" + dmh
        }
    }

}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UpMH, DownMH, and FACILITYID are the column names in the main line FC.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 17:35:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1480602#M1482</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-06-13T17:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1480606#M1483</link>
      <description>&lt;P&gt;Also, when returning a dict, there is no need to choose a field in the AR pane.&lt;/P&gt;&lt;P&gt;However, there is a bug, and if you want to use this data in ArcGIS Server less than version 10.9, just populate the "Field" box.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RhettZufelt_0-1717025038610.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/105720iE3E301C063E46EB2/image-size/large?v=v2&amp;amp;px=999" role="button" title="RhettZufelt_0-1717025038610.png" alt="RhettZufelt_0-1717025038610.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As you can see by the minimum version required.&amp;nbsp; The ONLY difference between these two rules is that I picked the FacilityID field in one.&amp;nbsp; However, it will still populate all the fields in the result dict.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 23:25:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1480606#M1483</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-05-29T23:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate From and To Endpoint IDs (from one of several point feature classes)</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1493824#M1489</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/15530"&gt;@RhettZufelt&lt;/a&gt;&amp;nbsp;this is fantastic, works like a charm! I was getting a "null geometry" error when validating in the Expression Builder. I simplified the the lines related grabbing the origin and endpoints of the line, which seemed to resolve the error.&lt;/P&gt;&lt;P&gt;var orig_point = line_shape.paths[0][0]&lt;/P&gt;&lt;P&gt;var end_point = line_shape.paths[-1][-1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2024 16:08:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-from-and-to-endpoint-ids-from-one-of/m-p/1493824#M1489</guid>
      <dc:creator>NathanGEOregon</dc:creator>
      <dc:date>2024-06-17T16:08:56Z</dc:date>
    </item>
  </channel>
</rss>

