<?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: Arcade expression to populate a field from one point layer to another that are on the same line in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371121#M1260</link>
    <description>&lt;P&gt;Hi Mike,&lt;/P&gt;&lt;P&gt;I want this to run each time I add or edit a hydrant.&lt;/P&gt;</description>
    <pubDate>Wed, 17 Jan 2024 17:51:03 GMT</pubDate>
    <dc:creator>GIS_geek</dc:creator>
    <dc:date>2024-01-17T17:51:03Z</dc:date>
    <item>
      <title>Arcade expression to populate a field from one point layer to another that are on the same line</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371096#M1257</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;My organization is moving from Geometric Network to Utility Network and that means we have to move all of our Attribute Assistant methods to Attribute Rules. I was hoping to get assistance on one of them.&lt;/P&gt;&lt;P&gt;We number fire hydrants based on the corresponding valve. Both points are on the same line and that is the only relationship between them.&amp;nbsp; All three features (hydrant, valve, and line) are in the same geodatabase.&amp;nbsp; The attached code I am running comes up with an error&amp;nbsp; mentioning "Invalid expression. Error on line 5. Wrong number of arguments." Hoping to get some help on this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var valves = FeatureSetByName($datastore, "dwSystemValve");
var hydrants = FeatureSetByName($datastore, "dwHydrant");
var fireLines = FeatureSetByName($datastore, "dwLateralLine");

var intersectingValve = Intersects(valves, fireLines, true);
var intersectingHydrant = Intersects(hydrants, fireLines, true);

var commonFireLine = Filter(intersectingValve, intersectingHydrant);

var valveField = "NUM";
var hydrantField = "NUM";

var result = {};

for (var i in commonFireLine) {
    var valveValue = commonFireLine[i].attributes[valveField];
    var hydrantValue = commonFireLine[i].attributes[hydrantField];

    result[valveValue] = hydrantValue;
}

result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 17:33:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371096#M1257</guid>
      <dc:creator>GIS_geek</dc:creator>
      <dc:date>2024-01-17T17:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate a field from one point layer to another that are on the same line</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371106#M1258</link>
      <description>&lt;P&gt;Vavles is a featureset, sort like the path to the class on disk.&amp;nbsp; You cannot intersect a featureSet with a featureSet.&amp;nbsp; You need to loop over the features, such as for (var feat in valves)&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 17:43:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371106#M1258</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-01-17T17:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate a field from one point layer to another that are on the same line</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371111#M1259</link>
      <description>&lt;P&gt;Bigger question, what and when do you want this rule to fire?&amp;nbsp; Is this something you want run on the entire database?&amp;nbsp; Do you want it to run each time you edit a hydrant, or valve, etc?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 17:46:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371111#M1259</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-01-17T17:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate a field from one point layer to another that are on the same line</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371121#M1260</link>
      <description>&lt;P&gt;Hi Mike,&lt;/P&gt;&lt;P&gt;I want this to run each time I add or edit a hydrant.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 17:51:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371121#M1260</guid>
      <dc:creator>GIS_geek</dc:creator>
      <dc:date>2024-01-17T17:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate a field from one point layer to another that are on the same line</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371247#M1261</link>
      <description>&lt;P&gt;Hopefully this gets you closer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var valves = FeatureSetByName($datastore, "dwSystemValve");
var fireLines = FeatureSetByName($datastore, "dwLateralLine");

var intersecting_lines = Intersects(fireLines, $feature);

valves_to_update = [];
for (var lat_line in intersecting_lines)
{
    var intersecting_valves = Intersects(valves, lat_line);
    for(var valve in intersecting_valves){
        push(valves_to_update, {'globalID':valve.globalid,
            'attributes': {
                'num': lat_line.num
            }})
    }
}

return {
    'edit': [{
        'className': 'valve',
        'updates': valves_to_update
    }]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 10:49:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371247#M1261</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-01-18T10:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate a field from one point layer to another that are on the same line</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371252#M1262</link>
      <description>&lt;P&gt;What's going on in line 4 and what's the purpose of loop within a loop?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 20:45:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371252#M1262</guid>
      <dc:creator>Ed_</dc:creator>
      <dc:date>2024-01-17T20:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate a field from one point layer to another that are on the same line</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371331#M1263</link>
      <description>&lt;P&gt;Getting an error, "Invalid expression. Error on line 11. Close parenthesis expected."&amp;nbsp; Not sure why since I see the closed parenthesis in line 14.&amp;nbsp; I am a bit of a novice so not sure what to look for now.&amp;nbsp; I appreciate your time and effort on this &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/188597"&gt;@MikeMillerGIS&lt;/a&gt; .&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 22:13:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371331#M1263</guid>
      <dc:creator>GIS_geek</dc:creator>
      <dc:date>2024-01-17T22:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate a field from one point layer to another that are on the same line</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371333#M1264</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/554773"&gt;@Ed_&lt;/a&gt;&amp;nbsp; A lot of this was from other code I found in other forums. I thought applied to what I am trying to accomplish so I was testing it out.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 22:22:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371333#M1264</guid>
      <dc:creator>GIS_geek</dc:creator>
      <dc:date>2024-01-17T22:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate a field from one point layer to another that are on the same line</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371360#M1265</link>
      <description>I did not format the dictionary correctly on line 11, will fix it tomorrow when back on my PC. Needs a { in front of global I'd and one more } on 14 after the other one.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Jan 2024 23:21:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371360#M1265</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-01-17T23:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate a field from one point layer to another that are on the same line</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371546#M1266</link>
      <description>&lt;P&gt;If you are referring to my post, line 4 intersects the hydrant with the lateral lines.&amp;nbsp; As the OP said they want this to run on the hydrant.&amp;nbsp; Is every hydrant connected to only one line?&amp;nbsp; I have no idea, I do not have access to his data, so without that knowledge, the only safe way to code it is loop over all results and find the valves that are connected to each lateral line.&amp;nbsp; Now in reality, hydrants connect to one line, so I could have called First() on the result, but that info was not provided.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 10:53:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371546#M1266</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-01-18T10:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate a field from one point layer to another that are on the same line</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371885#M1267</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/188597"&gt;@MikeMillerGIS&lt;/a&gt;hydrants are connected to only one line.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 20:18:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371885#M1267</guid>
      <dc:creator>GIS_geek</dc:creator>
      <dc:date>2024-01-18T20:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate a field from one point layer to another that are on the same line</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371926#M1268</link>
      <description>&lt;P&gt;You can adjust the code to call First then and skip the first loop.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 21:03:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1371926#M1268</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-01-18T21:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate a field from one point layer to another that are on the same line</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1373077#M1274</link>
      <description>&lt;P&gt;Hi Mike,&lt;/P&gt;&lt;P&gt;I updated the code as best as I could as shown below.&amp;nbsp; I am receiving the following error "Invalid expression. Error on line 8. Expected convertable to geometry."&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var valves = FeatureSetByName($datastore, "dwSystemValve");
var fireLines = FeatureSetByName($datastore, "dwLateralLine");

var intersecting_lines = First(Intersects(fireLines, $feature));

// valves_to_update = [];
// for (var lat_line in intersecting_lines)
    var intersecting_valves = Intersects(valves, fireLines);
    for(var valve in intersecting_valves){
        push(valves_to_update, {'globalID':valve.globalid,
            'attributes': {
                'num': lat_line.num
            }})
    }

return {
    'edit': [{
        'className': 'valve',
        'updates': valves_to_update
    }]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 18:07:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1373077#M1274</guid>
      <dc:creator>GIS_geek</dc:creator>
      <dc:date>2024-01-22T18:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate a field from one point layer to another that are on the same line</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1373532#M1276</link>
      <description>&lt;P&gt;this line is trying to intersect two database classes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;var intersecting_valves = Intersects(valves, fireLines);&lt;/P&gt;&lt;P&gt;You need to change that to the first line&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var intersecting_valves = Intersects(valves, intersecting_lines );&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;why did you comment out this?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// valves_to_update = [];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;needs to be&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var valves_to_update = [];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 17:16:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-to-populate-a-field-from-one/m-p/1373532#M1276</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-01-23T17:16:45Z</dc:date>
    </item>
  </channel>
</rss>

