<?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: Auto Increment ID Field in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1141650#M40382</link>
    <description>&lt;P&gt;Thank you for your reply. I created the survey using the online version of S123. Do I need to use Survey123 Connect?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 08 Feb 2022 16:05:38 GMT</pubDate>
    <dc:creator>AmandaBeck</dc:creator>
    <dc:date>2022-02-08T16:05:38Z</dc:date>
    <item>
      <title>Auto Increment ID Field</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1140051#M40242</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a survey with Survey123, which I have connected to Integromat in a scenario for generating a report every time a survey is submitted, and at the same time, emails the submitter an attachment .pdf with an ID number on it. At first, I was using the ObjectID field as my ID identifier, but after further reading and running into my own issue of every time I tried to "test" my scenario, a new survey entry was submitted, therefore using ObjectID numbers which cannot be deleted. The problem is, once I get my scenario working properly, I need the ObjectID field to restart at 1,2,3 and so forth. Obviously, it is not possible to restart ObjectID's without restarting and recreating the survey (and all the other steps I've taken to get here), but I was hoping there would be another solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've read about auto incrementation, but I cannot figure out how to get it to work. The survey I created was authored in the web version of Survey123.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also had a thought of adding a field to my Survey123 table (not sure how to do that) and putting the auto incremented ID number in there, which could be calculated from a date/time field I currently have. But I'm not sure how to do that either, or if it is even possible.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anybody has any thoughts on this, it would be greatly appreciated! P.S. I have read through all the posts on Auto Incrementing with Survey123. Hopefully somebody has something new to say.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 19:52:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1140051#M40242</guid>
      <dc:creator>AmandaBeck</dc:creator>
      <dc:date>2022-02-02T19:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Increment ID Field</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1140060#M40243</link>
      <description>&lt;P&gt;You can get something like this to work using &lt;A href="https://community.esri.com/t5/arcgis-survey123-blog/extending-survey123-smart-forms-with-custom-js/ba-p/898782" target="_self"&gt;custom JS functions in your survey&lt;/A&gt;. We use a function like this to pull the next ID in line for a layer, based on the total count of features.&lt;/P&gt;&lt;P&gt;This does assume there are no gaps, and it has the potential to create duplicates if two surveys are being filled out at once. But working with the total count, you'll only have those two as duplicates, and the id number gets back on track with the following submission.&lt;/P&gt;&lt;P&gt;For our survey, this outputs a padded string, so '003' instead of 3. But you could easily adjust that.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;function nextid() {

    var lyr = "service-url-for-layer";

    var xmlhttp = new XMLHttpRequest();

    var url = lyr + "/query?where=1=1&amp;amp;returnCountOnly=true&amp;amp;f=json"
        
    xmlhttp.open("GET", url, false);
		xmlhttp.send();

	if (xmlhttp.status!==200){
        return '';
    } else {

        var responseJSON=JSON.parse(xmlhttp.responseText)
        if (responseJSON.error){
            return '';
        } else {
            var r =  responseJSON['count'];
        }
    }

    var next = String(r + 1)

    var outstr = next.padStart(3, '0')

    return outstr
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 20:05:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1140060#M40243</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-02-02T20:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Increment ID Field</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1141650#M40382</link>
      <description>&lt;P&gt;Thank you for your reply. I created the survey using the online version of S123. Do I need to use Survey123 Connect?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 16:05:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1141650#M40382</guid>
      <dc:creator>AmandaBeck</dc:creator>
      <dc:date>2022-02-08T16:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Increment ID Field</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1141657#M40384</link>
      <description>&lt;P&gt;Yes, this would be something in Survey123 Connect. I don't know that you can accomplish this from the web version.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 16:18:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1141657#M40384</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-02-08T16:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Increment ID Field</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1180774#M43109</link>
      <description>&lt;P&gt;Hi Josh,&lt;/P&gt;&lt;P&gt;Would you be able to share the xls of this. I am looking to do same thing auto increment but with the date in front of incrementing values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 19:24:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1180774#M43109</guid>
      <dc:creator>DonovanC</dc:creator>
      <dc:date>2022-06-07T19:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Increment ID Field</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1180817#M43114</link>
      <description>&lt;P&gt;Here you go! The "investigation number" is what auto-increments, using year value from the complaint_year field, outputting text like "22-003".&lt;/P&gt;&lt;TABLE width="36.72481754673535%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="6.638566912539515%"&gt;type&lt;/TD&gt;&lt;TD width="17.80821917808219%"&gt;name&lt;/TD&gt;&lt;TD width="10.853530031612223%"&gt;label&lt;/TD&gt;&lt;TD width="1.4245014245014245%"&gt;calculation&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="6.638566912539515%"&gt;hidden&lt;/TD&gt;&lt;TD width="17.80821917808219%"&gt;the_token&lt;/TD&gt;&lt;TD width="10.853530031612223%"&gt;Token&lt;/TD&gt;&lt;TD width="1.4245014245014245%"&gt;pulldata("@property", "token")&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="6.638566912539515%"&gt;integer&lt;/TD&gt;&lt;TD width="17.80821917808219%"&gt;complaint_year&lt;/TD&gt;&lt;TD width="10.853530031612223%"&gt;Complaint Year&lt;/TD&gt;&lt;TD width="1.4245014245014245%"&gt;int(format-date(now(), '%Y'))&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="6.638566912539515%"&gt;text&lt;/TD&gt;&lt;TD width="17.80821917808219%"&gt;investigation_number&lt;/TD&gt;&lt;TD width="10.853530031612223%"&gt;Investigation Number&lt;/TD&gt;&lt;TD width="1.4245014245014245%"&gt;pulldata("@javascript", "functions.js", "nextpermit", ${complaint_year}, ${the_token})&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 07 Jun 2022 21:45:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1180817#M43114</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-06-07T21:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Increment ID Field</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1181088#M43139</link>
      <description>&lt;P&gt;What is the reason behind grabbing the token? My end goal is to implement this function in AGOL. Would the code be very similar to the code posted above?&lt;/P&gt;&lt;P&gt;Thanks again for your help, still new at learning these scripts in S123&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 14:34:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1181088#M43139</guid>
      <dc:creator>DonovanC</dc:creator>
      <dc:date>2022-06-08T14:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Increment ID Field</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1181094#M43141</link>
      <description>&lt;P&gt;When the script&amp;nbsp; makes a request to&amp;nbsp;&lt;STRONG&gt;/server/rest/services/hosted/some-feature-service/0/query&lt;/STRONG&gt;, one of the URL parameters that must be supplied is the token. If you're accessing a public layer, you can probably omit it, but if the layer isn't shared publicly, the token is what tells the service you're authorized to see it. I would imagine the code could translate directly to an AGOL environment.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 14:40:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1181094#M43141</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-06-08T14:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Increment ID Field</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1184804#M43362</link>
      <description>&lt;P&gt;Thank you for&amp;nbsp; your reply. I am still working on getting this to work. Is there a way I can have it so the year does not show? I want a field to populate that would be 001, 002, 003, etc. that is never-ending.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this doable in S123 Connect and if so,&amp;nbsp; how would I accomplish it?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 18:58:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1184804#M43362</guid>
      <dc:creator>AmandaBeck</dc:creator>
      <dc:date>2022-06-21T18:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Increment ID Field</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1228078#M45818</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Would you mind helping me with this. I've copied the JavaScript and the xls into Survey123 but the investigation number is returning "NaN".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Jerry&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 20:28:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1228078#M45818</guid>
      <dc:creator>JerrySneary</dc:creator>
      <dc:date>2022-11-02T20:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Increment ID Field</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1264912#M47829</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&lt;/P&gt;&lt;P&gt;I have been trying to use the solution proposed by you for calculating "investigation number", however I receive null value once submitting a new entry.&lt;/P&gt;&lt;P&gt;Thank you for any suggestions!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Monika&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 13:54:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1264912#M47829</guid>
      <dc:creator>MonikaSamorajska</dc:creator>
      <dc:date>2023-03-07T13:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Increment ID Field</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1264924#M47830</link>
      <description>&lt;P&gt;Monika,&lt;/P&gt;&lt;P&gt;In recent updates, Survey123 now has a method &lt;STRONG&gt;pulldata("@layer"...)&lt;/STRONG&gt; that can accomplish this sort of thing without any complex JS functions. It's much easier to work with than the original solution to this post.&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;</description>
      <pubDate>Tue, 07 Mar 2023 14:28:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/auto-increment-id-field/m-p/1264924#M47830</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-03-07T14:28:25Z</dc:date>
    </item>
  </channel>
</rss>

