<?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: Find Nearest in Field Maps Form in ArcGIS Field Maps Questions</title>
    <link>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602763#M10680</link>
    <description>&lt;P&gt;just occurred to me I did make one other change, The variable name 'distance', I modified to distance1 , apologies for omitting that bit.&amp;nbsp; &amp;nbsp;you should see that as an error when authoring the form.&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarkBockenhauer_1-1743776628303.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/129479i38E2FD9ACA50CE50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarkBockenhauer_1-1743776628303.png" alt="MarkBockenhauer_1-1743776628303.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;MarkBockenhauer_1-1743776628303.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Apr 2025 14:24:03 GMT</pubDate>
    <dc:creator>MarkBockenhauer</dc:creator>
    <dc:date>2025-04-04T14:24:03Z</dc:date>
    <item>
      <title>Find Nearest in Field Maps Form</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602597#M10672</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;I’m writing a calculated expression to populate a field in a Field Maps form. The function is to find the nearest creek feature and extract a value to populate the field in my new point. All new points will be very close to a creek.&amp;nbsp; As a matter of fact, the collection tech may be standing directly in the water so finding a close feature isn’t an issue.&amp;nbsp; When I run the script within the form’s calculated expression the result is null, not an error, which leads me to believe it’s executing properly. Since I haven't actually digitized a point yet there’s no location from which to calculate.&amp;nbsp; However, when I test collecting a point in field maps the calculation fails. &amp;nbsp;Any pointers would be greatly appreciated.&amp;nbsp; Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Get the geometry of the new digitized point&lt;/P&gt;&lt;P&gt;var pointGeometry = Geometry($feature);&lt;/P&gt;&lt;P&gt;var nearestCreek = null;&lt;/P&gt;&lt;P&gt;var nearestDistance = null;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Access the Creek Reaches 2025 feature set&lt;/P&gt;&lt;P&gt;var creeks = FeatureSetByName($map, "Inspection 2025/Creek Reaches 2025");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Loop through each creek to find the nearest one&lt;/P&gt;&lt;P&gt;for (var creek in creeks) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; var creekGeometry = Geometry(creek);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; var distance = Distance(pointGeometry, creekGeometry);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; // Check if this is the closest creek found so far&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; if (nearestDistance == null || distance &amp;lt; nearestDistance) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nearestDistance = distance;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nearestCreek = creek;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Extract the desired field value (e.g., REACH) from the nearest creek feature&lt;/P&gt;&lt;P&gt;var reachName = null;&lt;/P&gt;&lt;P&gt;if (nearestCreek != null) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; reachName = nearestCreek.REACH; // Ensure the field name matches the one in your dataset&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Return the reach name to populate the Reach_Name field&lt;/P&gt;&lt;P&gt;return reachName;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 00:04:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602597#M10672</guid>
      <dc:creator>Scott_Gowan</dc:creator>
      <dc:date>2025-04-04T00:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Find Nearest in Field Maps Form</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602753#M10678</link>
      <description>&lt;P&gt;I tried your script, it works.&amp;nbsp; &amp;nbsp;I just changed the creek layer name and the field name to match my test data.&lt;/P&gt;&lt;P&gt;Yes, it will be null if your point features does not exist, but with features in the hosted feature service, it works.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarkBockenhauer_0-1743775015136.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/129478i6A9A4A69595359A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarkBockenhauer_0-1743775015136.png" alt="MarkBockenhauer_0-1743775015136.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;MarkBockenhauer_0-1743775015136.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 13:58:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602753#M10678</guid>
      <dc:creator>MarkBockenhauer</dc:creator>
      <dc:date>2025-04-04T13:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Find Nearest in Field Maps Form</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602757#M10679</link>
      <description>&lt;P&gt;Hey Mark,&lt;/P&gt;&lt;P&gt;Thanks so much for the quick reply and confirming the script is correct.&amp;nbsp; For me it "fails" when I insert a point in Field Maps so perhaps I have a simple improper setting in the form.&amp;nbsp; Great to know that the script is correct though so I can eliminate that issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&amp;nbsp; Scott&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 14:16:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602757#M10679</guid>
      <dc:creator>Scott_Gowan</dc:creator>
      <dc:date>2025-04-04T14:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: Find Nearest in Field Maps Form</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602763#M10680</link>
      <description>&lt;P&gt;just occurred to me I did make one other change, The variable name 'distance', I modified to distance1 , apologies for omitting that bit.&amp;nbsp; &amp;nbsp;you should see that as an error when authoring the form.&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarkBockenhauer_1-1743776628303.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/129479i38E2FD9ACA50CE50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarkBockenhauer_1-1743776628303.png" alt="MarkBockenhauer_1-1743776628303.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;MarkBockenhauer_1-1743776628303.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 14:24:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602763#M10680</guid>
      <dc:creator>MarkBockenhauer</dc:creator>
      <dc:date>2025-04-04T14:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Find Nearest in Field Maps Form</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602764#M10681</link>
      <description>&lt;P&gt;Hey Mark,&amp;nbsp; Just to confirm.&amp;nbsp; In your scenario above were you adding a new point or updating an existing point?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 14:24:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602764#M10681</guid>
      <dc:creator>Scott_Gowan</dc:creator>
      <dc:date>2025-04-04T14:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: Find Nearest in Field Maps Form</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602765#M10682</link>
      <description>&lt;P&gt;Interesting,&amp;nbsp; I didn't get that flagged as an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 14:28:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602765#M10682</guid>
      <dc:creator>Scott_Gowan</dc:creator>
      <dc:date>2025-04-04T14:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: Find Nearest in Field Maps Form</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602797#M10684</link>
      <description>&lt;P&gt;both work,&amp;nbsp; new and updating existing.&amp;nbsp; I have shared my test map public for the moment, if you would like to take a look&amp;nbsp;&amp;nbsp;&lt;A href="https://www.arcgis.com/home/item.html?id=94c10beba7fb4a87b3cebed1750355c0" target="_blank"&gt;https://www.arcgis.com/home/item.html?id=94c10beba7fb4a87b3cebed1750355c0&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 14:53:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1602797#M10684</guid>
      <dc:creator>MarkBockenhauer</dc:creator>
      <dc:date>2025-04-04T14:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: Find Nearest in Field Maps Form</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1603078#M10691</link>
      <description>&lt;P&gt;Got it.&amp;nbsp; Thanks so much for your effort.&amp;nbsp; &amp;nbsp;This will be useful in so many other apps.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;Scott&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Apr 2025 14:43:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/find-nearest-in-field-maps-form/m-p/1603078#M10691</guid>
      <dc:creator>Scott_Gowan</dc:creator>
      <dc:date>2025-04-06T14:43:26Z</dc:date>
    </item>
  </channel>
</rss>

