<?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 Survey123: 'File not found: zone_lookup.js' Error – Auto-Populating Reach Number by Location in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-file-not-found-zone-lookup-js-error-auto/m-p/1634718#M63443</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm building a &lt;STRONG&gt;Survey123 form in Connect&lt;/STRONG&gt; to collect habitat data. I want to &lt;STRONG&gt;automatically populate the "Reach Number" field&lt;/STRONG&gt; based on the user's GPS location, using a polygon layer I’ve already created (each polygon represents a habitat reach zone).&lt;/P&gt;&lt;P&gt;Right now, I’m attempting to do this with a JavaScript file (zone_lookup.js) and the pulldata("@javascript") function. However, I’m getting the following error in the field app:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;STRONG&gt;File not found: zone_lookup.js&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Here’s what I’ve done so far:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;I referenced the JS file in the XLSForm with pulldata("@javascript", "zone_lookup.js", "getZone", ${gps_location})&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;Here is JS&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="c"&gt;function findZone(lat, lon, zones) {
    for (var i = 0; i &amp;lt; zones.features.length; i++) {
        var zone = zones.features[i];
        var coordinates = zone.geometry.coordinates[0];
        if (pointInPolygon([lon, lat], coordinates)) {
            return zone.properties.reach_ID; // Adjust to your attribute
        }
    }
    return "Unknown";
}

// Basic point-in-polygon function
function pointInPolygon(point, vs) {
    var x = point[0], y = point[1];
    var inside = false;
    for (var i = 0, j = vs.length - 1; i &amp;lt; vs.length; j = i++) {
        var xi = vs[i][0], yi = vs[i][1];
        var xj = vs[j][0], yj = vs[j][1];
        var intersect = ((yi &amp;gt; y) != (yj &amp;gt; y)) &amp;amp;&amp;amp;
                        (x &amp;lt; (xj - xi) * (y - yi) / (yj - yi) + xi);
        if (intersect) inside = !inside;
    }
    return inside;
}
​&lt;/LI-CODE&gt;&lt;P&gt;Before I dive deeper, I’m wondering:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;What’s the proper way to structure the zone_lookup.js file to query a polygon feature based on location?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Is there a better approach to this (like using pulldata("@layer")) if I already have a hosted feature layer with the polygon zones?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Will either of these methods work &lt;STRONG&gt;offline&lt;/STRONG&gt; in the field app?&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Thanks for any help — and I’m happy to share my XLSForm if needed.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jul 2025 19:03:00 GMT</pubDate>
    <dc:creator>IsabelleCroteau</dc:creator>
    <dc:date>2025-07-21T19:03:00Z</dc:date>
    <item>
      <title>Survey123: 'File not found: zone_lookup.js' Error – Auto-Populating Reach Number by Location</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-file-not-found-zone-lookup-js-error-auto/m-p/1634718#M63443</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm building a &lt;STRONG&gt;Survey123 form in Connect&lt;/STRONG&gt; to collect habitat data. I want to &lt;STRONG&gt;automatically populate the "Reach Number" field&lt;/STRONG&gt; based on the user's GPS location, using a polygon layer I’ve already created (each polygon represents a habitat reach zone).&lt;/P&gt;&lt;P&gt;Right now, I’m attempting to do this with a JavaScript file (zone_lookup.js) and the pulldata("@javascript") function. However, I’m getting the following error in the field app:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;STRONG&gt;File not found: zone_lookup.js&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Here’s what I’ve done so far:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;I referenced the JS file in the XLSForm with pulldata("@javascript", "zone_lookup.js", "getZone", ${gps_location})&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;Here is JS&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="c"&gt;function findZone(lat, lon, zones) {
    for (var i = 0; i &amp;lt; zones.features.length; i++) {
        var zone = zones.features[i];
        var coordinates = zone.geometry.coordinates[0];
        if (pointInPolygon([lon, lat], coordinates)) {
            return zone.properties.reach_ID; // Adjust to your attribute
        }
    }
    return "Unknown";
}

// Basic point-in-polygon function
function pointInPolygon(point, vs) {
    var x = point[0], y = point[1];
    var inside = false;
    for (var i = 0, j = vs.length - 1; i &amp;lt; vs.length; j = i++) {
        var xi = vs[i][0], yi = vs[i][1];
        var xj = vs[j][0], yj = vs[j][1];
        var intersect = ((yi &amp;gt; y) != (yj &amp;gt; y)) &amp;amp;&amp;amp;
                        (x &amp;lt; (xj - xi) * (y - yi) / (yj - yi) + xi);
        if (intersect) inside = !inside;
    }
    return inside;
}
​&lt;/LI-CODE&gt;&lt;P&gt;Before I dive deeper, I’m wondering:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;What’s the proper way to structure the zone_lookup.js file to query a polygon feature based on location?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Is there a better approach to this (like using pulldata("@layer")) if I already have a hosted feature layer with the polygon zones?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Will either of these methods work &lt;STRONG&gt;offline&lt;/STRONG&gt; in the field app?&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Thanks for any help — and I’m happy to share my XLSForm if needed.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jul 2025 19:03:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/survey123-file-not-found-zone-lookup-js-error-auto/m-p/1634718#M63443</guid>
      <dc:creator>IsabelleCroteau</dc:creator>
      <dc:date>2025-07-21T19:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Survey123: 'File not found: zone_lookup.js' Error – Auto-Populating Reach Number by Location</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-file-not-found-zone-lookup-js-error-auto/m-p/1634944#M63449</link>
      <description>&lt;P&gt;the pulldata (@layer)&amp;nbsp; point in polygon usage might fit better however it is only going to work online.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-pulldata-quot-layer/ba-p/1224415" target="_blank"&gt;https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-pulldata-quot-layer/ba-p/1224415&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There doesn't&amp;nbsp; currently appear to be a way to pull data from an offline source.&amp;nbsp; This was an interesting take:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-survey123-questions/any-similar-function-to-pulldata-to-work-with-mmpk/td-p/1306835" target="_blank"&gt;https://community.esri.com/t5/arcgis-survey123-questions/any-similar-function-to-pulldata-to-work-with-mmpk/td-p/1306835&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Another thought would be, could you handle the zone field in post processing? Like write a python script to programmatically fill the zone field after submission based on the point coordinates collected in the survey.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2025 13:41:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/survey123-file-not-found-zone-lookup-js-error-auto/m-p/1634944#M63449</guid>
      <dc:creator>Neal_t_k</dc:creator>
      <dc:date>2025-07-22T13:41:55Z</dc:date>
    </item>
  </channel>
</rss>

