<?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: Stop Survey123 Entry if Duplicate Project ID Entered in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1405006#M55938</link>
    <description>&lt;P&gt;Thanks for your work, I've been looking exactly for this for 2 days.&lt;/P&gt;&lt;P&gt;It works like a charm !&lt;/P&gt;</description>
    <pubDate>Wed, 03 Apr 2024 02:47:09 GMT</pubDate>
    <dc:creator>PierreloupDucroix</dc:creator>
    <dc:date>2024-04-03T02:47:09Z</dc:date>
    <item>
      <title>Stop Survey123 Entry if Duplicate Project ID Entered</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1151515#M41128</link>
      <description>&lt;P&gt;Hi -&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am hoping to add some functionality into my XLSForm that would prevent data entry if a duplicate Project ID is entered into Survey123. I would like this to happen as soon as the user enters a Project ID into the form as the form is quite long (it would really stink to get to the end and then see this error!).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I feel like a JavaScript function would be the best method for doing this, however I am struggling to find an example and really do not know how to write one myself.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not think pulldata() would be a reasonable solution for this as it would be extremely cumbersome to maintain the external CSV - new projects are being entered weekly. The ideal solution would be a way to look back at the hosted feature service, check the field and see if the Project ID already exists.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am also wondering if the "Unique" setting could be used to accomplish this; I suspect that it would not cause error until going to submit the survey form.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erica_tefft_0-1646688944871.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/35798i4C9E8B623D35AD38/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erica_tefft_0-1646688944871.png" alt="erica_tefft_0-1646688944871.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any advice would be welcome!&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 21:36:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1151515#M41128</guid>
      <dc:creator>erica_poisson</dc:creator>
      <dc:date>2022-03-07T21:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Stop Survey123 Entry if Duplicate Project ID Entered</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1158322#M41658</link>
      <description>&lt;P&gt;I was able to get some help and figure out how to do this. I wanted to post the result here in case it is helpful to others.&lt;/P&gt;&lt;P&gt;I am using a custom JavaScript function and a series of hidden and relevant questions in the XLSForm to accomplish my goal - prevent the submission of a new Survey123 form if the file number entered is a duplicate value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, here is the JS function:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;/*
* JavaScript functions for Survey123
*/

function returnFeatures(DCR_File_Number, token, debugmode) {

    // Output value.  Initially set to an empty string (XLSForm null)
               let outValue = "";

               let layerURL = "https://URL GOES HERE/FeatureServer/0";
               let response ="";
               
               // Set up query parameters
               let f = "f=json";
               let where = `where=DCR_File_Number='${DCR_File_Number}'`; 
               let outFields = "outFields=*";
               let returnGeometry = "returnGeometry=false";
               let returnCount = "returnCount=1";
               let parameters = [f,where,outFields,returnGeometry,returnCount].join("&amp;amp;");
               
               let url = `${layerURL}/query?${parameters}`;
               

if (token){
     url = url + "&amp;amp;token=" + token;
    }

               // Create the request object
               let xhr = new XMLHttpRequest();
               // Make the request.  Note the 3rd parameter, which makes this a synchronous request
               xhr.open("GET", url, false);
               xhr.send();
               
               
               // Process the result
               if (xhr.readyState === xhr.DONE) {
                              if (xhr.status !== 200) {
                                             // The http request did not succeed
                                             return "bad request: " + url
                              } else {
                                                            // Parse the response into an object
                                             response = JSON.parse(xhr.responseText);
                                             if (response.error) {
                                                            return (debugmode? JSON.stringify(response.error):"");
                                             } else {
                                                            if (response.features[0]) {
                                                                           return "DCR File number is not unique"
                                                                           //JSON.stringify(response.features[0]);
                                                            } else {
                                                                           if (DCR_File_Number !== "") {
                                                                           return "DCR File number is unique"}
                                                                           //(debugmode? "No Features Found":"");
                                                            }
                                             }
                              }
               }
               
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next, I configured the XLSForm - here is what all of the populated columns look like (I hid all of the empty/non-relevant columns to fit this into one image):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erica_tefft_0-1648470843942.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37456i3F6BB9182215EF97/image-size/large?v=v2&amp;amp;px=999" role="button" title="erica_tefft_0-1648470843942.png" alt="erica_tefft_0-1648470843942.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When the user goes to enter a file number, if it is invalid (AKA a duplicate), they will see this message in the Survey123 form:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erica_tefft_1-1648470948538.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37457iF703D544DE961E79/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erica_tefft_1-1648470948538.png" alt="erica_tefft_1-1648470948538.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Because of line 6 in the XLSForm, they are prevented from submitting their form until they correct the DCR File Number so that it is unique.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When a unique DCR File Number is entered, this message appears and the user is able to submit:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erica_tefft_2-1648471029609.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37458i9FCD0FA53B3B68C9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erica_tefft_2-1648471029609.png" alt="erica_tefft_2-1648471029609.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This seems to work very well for my use case. Since this is a web-only form (users only complete from a desktop PC) this works perfectly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 12:38:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1158322#M41658</guid>
      <dc:creator>erica_poisson</dc:creator>
      <dc:date>2022-03-28T12:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: Stop Survey123 Entry if Duplicate Project ID Entered</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1370281#M53997</link>
      <description>&lt;P&gt;This is great! I've got it very close to working in my test case. Are you missing something in your screenshot of the xls form? I noticed that you have a "required message" and I don't see that in the form. I also wondered how to get the required error message to show up as they are entering data - mine only shows up if they try and submit.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 20:31:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1370281#M53997</guid>
      <dc:creator>EricaNova</dc:creator>
      <dc:date>2024-01-15T20:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Stop Survey123 Entry if Duplicate Project ID Entered</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1370504#M54005</link>
      <description>&lt;P&gt;Also, I noticed that if I try to edit the record, the user cannot submit it because it is reading it as a duplicate. That's odd.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 15:35:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1370504#M54005</guid>
      <dc:creator>EricaNova</dc:creator>
      <dc:date>2024-01-16T15:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: Stop Survey123 Entry if Duplicate Project ID Entered</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1370924#M54024</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/723412"&gt;@EricaNova&lt;/a&gt;&amp;nbsp;-&lt;/P&gt;&lt;P&gt;Within the Hint column, I also have this for the "not_valid_value_check" which was not included above:&amp;nbsp;&amp;lt;font color="#850419"&amp;gt;*This is required!*&amp;lt;/font&amp;gt;&lt;/P&gt;&lt;P&gt;Other than that, nothing is missing.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 13:17:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1370924#M54024</guid>
      <dc:creator>erica_poisson</dc:creator>
      <dc:date>2024-01-17T13:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Stop Survey123 Entry if Duplicate Project ID Entered</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1370925#M54025</link>
      <description>&lt;P&gt;I only use this within a "new entry" form. For my "update form" (which is used within a Dashboard) I've published a totally new Survey123 form where this function is not included. The DCR_File_Number attribute field is read only (and so are some other fields) to prevent editing of those values.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 13:19:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1370925#M54025</guid>
      <dc:creator>erica_poisson</dc:creator>
      <dc:date>2024-01-17T13:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: Stop Survey123 Entry if Duplicate Project ID Entered</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1370937#M54029</link>
      <description>&lt;P&gt;Ah, ok - thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 13:35:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1370937#M54029</guid>
      <dc:creator>EricaNova</dc:creator>
      <dc:date>2024-01-17T13:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Stop Survey123 Entry if Duplicate Project ID Entered</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1370938#M54030</link>
      <description>&lt;P&gt;You've really got it all worked out! I'd like to keep this fairly straightforward, so I think I'll modify it so this is just a warning and cross my fingers... sigh. Wish that Survey123 could do this, it seems like such a simple ask.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 13:36:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1370938#M54030</guid>
      <dc:creator>EricaNova</dc:creator>
      <dc:date>2024-01-17T13:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: Stop Survey123 Entry if Duplicate Project ID Entered</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1405006#M55938</link>
      <description>&lt;P&gt;Thanks for your work, I've been looking exactly for this for 2 days.&lt;/P&gt;&lt;P&gt;It works like a charm !&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 02:47:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1405006#M55938</guid>
      <dc:creator>PierreloupDucroix</dc:creator>
      <dc:date>2024-04-03T02:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Stop Survey123 Entry if Duplicate Project ID Entered</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1416909#M56564</link>
      <description>&lt;P&gt;Dear Erica&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for the information, are you able to share the form please, Maivha2006@gmail.com&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 07:38:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1416909#M56564</guid>
      <dc:creator>RENDANIMUDAU</dc:creator>
      <dc:date>2024-04-30T07:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Stop Survey123 Entry if Duplicate Project ID Entered</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1557636#M60040</link>
      <description>&lt;P&gt;Thank you erica_poisson.&amp;nbsp; I am attempting to use this in a survey to collect new features for an internal 'GeoGuessr' style game for GIS Day.&amp;nbsp; When I enter a duplicate value, it does not identify it as being duplicate until the very end of the survey, not at the beginning as anticipated.&amp;nbsp; Everything else is working, but it doesn't provide an error message until the end of the survey.&amp;nbsp; Attached is a sanitized .xlsx to remove our URLs/IDs, etc. and a screenshot of the data for reference and the messages we receive during (after!) entry.&amp;nbsp; I think I'm missing something small/basic somewhere...&amp;nbsp; Thanks for any help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;/*
 * JavaScript functions for Survey123
 */

function returnFeatures(map_user, token, debugmode) {

    // Output value.  Initially set to an empty string (XLSForm null)
               let outValue = "";

               let layerURL = "https://&amp;lt;our service url&amp;gt;";
               let response ="";
               
               // Set up query parameters
               let f = "f=json";
               let where = `where=map_user='${map_user}'`; 
               let outFields = "outFields=*";
               let returnGeometry = "returnGeometry=false";
               let returnCount = "returnCount=1";
               let parameters = [f,where,outFields,returnGeometry,returnCount].join("&amp;amp;");
               
               let url = `${layerURL}/query?${parameters}`;
               

if (token){
     url = url + "&amp;amp;token=" + token;
    }

               // Create the request object
               let xhr = new XMLHttpRequest();
               // Make the request.  Note the 3rd parameter, which makes this a synchronous request
               xhr.open("GET", url, false);
               xhr.send();
               
               
               // Process the result
               if (xhr.readyState === xhr.DONE) {
                              if (xhr.status !== 200) {
                                             // The http request did not succeed
                                             return "bad request: " + url
                              } else {
                                                            // Parse the response into an object
                                             response = JSON.parse(xhr.responseText);
                                             if (response.error) {
                                                            return (debugmode? JSON.stringify(response.error):"");
                                             } else {
                                                            if (response.features[0]) {
                                                                           return "That Player name is already taken, please enter a different name."
                                                                           //JSON.stringify(response.features[0]);
                                                            } else {
                                                                           if (map_user !== "") {
                                                                           return "Player name entered."}
                                                                           //(debugmode? "No Features Found":"");
                                                            }
                                             }
                              }
               }
               
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 17:13:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1557636#M60040</guid>
      <dc:creator>JustinWolff</dc:creator>
      <dc:date>2024-11-12T17:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Stop Survey123 Entry if Duplicate Project ID Entered</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1566936#M60438</link>
      <description>&lt;P&gt;I'm very sorry for the late reply. This is likely due to order of relevant statements within your Survey123 form. My pulldata() executes and then a series of questions with relevant statements show (or not) and allow a user to proceed (or not) with data entry.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 19:37:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/stop-survey123-entry-if-duplicate-project-id/m-p/1566936#M60438</guid>
      <dc:creator>erica_poisson</dc:creator>
      <dc:date>2024-12-10T19:37:04Z</dc:date>
    </item>
  </channel>
</rss>

