<?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 How to create a sequential unique ID in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-create-a-sequential-unique-id/m-p/109815#M4467</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a Survey123 form that will be used several times a day by over a hundred users. Every record (survey submitted) in my feature layer needs a unique ID. It isn't easy to&amp;nbsp;ensure unique numbers in Survey123.&amp;nbsp;&lt;SPAN style="font-size: 11.0pt;"&gt;I want to populate the Unique_ID field with COB1, &lt;SPAN&gt;COB1&lt;/SPAN&gt;, &lt;SPAN&gt;COB2,&amp;nbsp;&lt;/SPAN&gt;and so on. (I prefer that the starting number is 100). Once a&amp;nbsp;record is set, I can't change it again (it may have been exported). I think that a calculated field could be scheduled to run daily in ArcGIS Pro. (I don't entirely know how to do that.) I'm using AcrGIS Pro 2.6 on Windows 10. To start the sequence, I would need to count the number of non-null (or not empty string)&amp;nbsp;values in the&amp;nbsp;&lt;SPAN&gt;Unique_ID field.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;&lt;SPAN&gt;I'm new to ArcGIS Pro and Python.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;I wrote the code below from this example:&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/calculate-field-examples.htm"&gt;https://pro.arcgis.com/en/pro-app/tool-reference/data-management/calculate-field-examples.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rec=0&lt;/P&gt;&lt;P&gt;def autoIncrement():&lt;/P&gt;&lt;P&gt;&amp;nbsp;global rec&lt;/P&gt;&lt;P&gt;&amp;nbsp;pStart = 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;pInterval = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;if (rec == 0):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;rec = pStart&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;else:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;rec += pInterval&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;textRec = "COB" + str(rec)&lt;/P&gt;&lt;P&gt;return textRec&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To get the starting value of the sequence, I would need to count all non-empty fields (not null or not empty string). I think that this post shows how to do that:&amp;nbsp;&lt;A _jive_internal="true" href="https://community.esri.com/thread/224234-field-calculator-for-not-null-fields"&gt;https://community.esri.com/thread/224234-field-calculator-for-not-null-fields&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to put this all together. Am I on the right track? Again,&amp;nbsp;&lt;SPAN&gt;I'm new to ArcGIS Pro and Python.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chuck&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 01 Sep 2020 17:37:57 GMT</pubDate>
    <dc:creator>Soper_Chuck</dc:creator>
    <dc:date>2020-09-01T17:37:57Z</dc:date>
    <item>
      <title>How to create a sequential unique ID</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-create-a-sequential-unique-id/m-p/109815#M4467</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a Survey123 form that will be used several times a day by over a hundred users. Every record (survey submitted) in my feature layer needs a unique ID. It isn't easy to&amp;nbsp;ensure unique numbers in Survey123.&amp;nbsp;&lt;SPAN style="font-size: 11.0pt;"&gt;I want to populate the Unique_ID field with COB1, &lt;SPAN&gt;COB1&lt;/SPAN&gt;, &lt;SPAN&gt;COB2,&amp;nbsp;&lt;/SPAN&gt;and so on. (I prefer that the starting number is 100). Once a&amp;nbsp;record is set, I can't change it again (it may have been exported). I think that a calculated field could be scheduled to run daily in ArcGIS Pro. (I don't entirely know how to do that.) I'm using AcrGIS Pro 2.6 on Windows 10. To start the sequence, I would need to count the number of non-null (or not empty string)&amp;nbsp;values in the&amp;nbsp;&lt;SPAN&gt;Unique_ID field.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;&lt;SPAN&gt;I'm new to ArcGIS Pro and Python.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;I wrote the code below from this example:&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/calculate-field-examples.htm"&gt;https://pro.arcgis.com/en/pro-app/tool-reference/data-management/calculate-field-examples.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rec=0&lt;/P&gt;&lt;P&gt;def autoIncrement():&lt;/P&gt;&lt;P&gt;&amp;nbsp;global rec&lt;/P&gt;&lt;P&gt;&amp;nbsp;pStart = 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;pInterval = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;if (rec == 0):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;rec = pStart&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;else:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;rec += pInterval&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;textRec = "COB" + str(rec)&lt;/P&gt;&lt;P&gt;return textRec&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To get the starting value of the sequence, I would need to count all non-empty fields (not null or not empty string). I think that this post shows how to do that:&amp;nbsp;&lt;A _jive_internal="true" href="https://community.esri.com/thread/224234-field-calculator-for-not-null-fields"&gt;https://community.esri.com/thread/224234-field-calculator-for-not-null-fields&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to put this all together. Am I on the right track? Again,&amp;nbsp;&lt;SPAN&gt;I'm new to ArcGIS Pro and Python.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chuck&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Sep 2020 17:37:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-create-a-sequential-unique-id/m-p/109815#M4467</guid>
      <dc:creator>Soper_Chuck</dc:creator>
      <dc:date>2020-09-01T17:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a sequential unique ID</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-create-a-sequential-unique-id/m-p/109816#M4468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you taken a look at &lt;A href="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/create-database-sequence.htm"&gt;Database Sequences&lt;/A&gt;? You would then need to create an &lt;A href="https://pro.arcgis.com/en/pro-app/help/data/geodatabases/overview/an-overview-of-attribute-rules.htm"&gt;Attribute Rule&lt;/A&gt;&amp;nbsp;and you use Arcade rather than python in the rule.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another approach is to use the FID or OID of your record and concatenate it with your prefix in the field calculator:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;yourFieldName &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; f&lt;SPAN class="string token"&gt;'COB{!OBJECTID!}'&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;this uses what is called &lt;A href="https://realpython.com/python-formatted-output/"&gt;f-strings&lt;/A&gt; that is a relatively new feature in python 3.x.&amp;nbsp; The object id field is a built in sequence so it is always unique and will never be re-used if the record is deleted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Sep 2020 17:54:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-create-a-sequential-unique-id/m-p/109816#M4468</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2020-09-01T17:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a sequential unique ID</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-create-a-sequential-unique-id/m-p/109817#M4469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joe, Thank you very much for your response. I appreciate it. I had to fix some other issues in Survey123. I'll look into your suggestions within the next few days. Thanks, Chuck&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Sep 2020 23:41:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-create-a-sequential-unique-id/m-p/109817#M4469</guid>
      <dc:creator>Soper_Chuck</dc:creator>
      <dc:date>2020-09-03T23:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a sequential unique ID</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-create-a-sequential-unique-id/m-p/109818#M4470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using the ObjectID seemed like the best approach. I don't need an exact sequence. I just can't have the&amp;nbsp;field data ever change. Using the following works great. Thanks for your help.&lt;/P&gt;&lt;P&gt;f'COB{100 + !objectid!}'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A co-worker and I also&amp;nbsp;discovered that the following (older style Python) also works:&lt;/P&gt;&lt;P&gt;'COB' + str(100 + !objectid!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chuck&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Sep 2020 01:46:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-create-a-sequential-unique-id/m-p/109818#M4470</guid>
      <dc:creator>Soper_Chuck</dc:creator>
      <dc:date>2020-09-05T01:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a sequential unique ID</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-create-a-sequential-unique-id/m-p/109819#M4471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;"COB100{}".format(!objectid!)

# --- or

f"COB100{!objectid!}"&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;For more current format string operations with 2 variants&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:35:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-create-a-sequential-unique-id/m-p/109819#M4471</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-12-11T06:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a sequential unique ID</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-create-a-sequential-unique-id/m-p/1286117#M68822</link>
      <description>&lt;P&gt;I am trying to get a unique ID field populated. The field is CarteID. I want a prefix of SSP and use the ObjectID field. Example: ObjectID is 10234 - I want the CarteID to be SSP10234. Using Python 3, how do I use the field calculator to populate this field. What Expression do I use?&lt;/P&gt;&lt;P&gt;Then, going forward, is there a way to automatically populated this field when someone adds a new feature?&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 14:26:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-create-a-sequential-unique-id/m-p/1286117#M68822</guid>
      <dc:creator>AndrewAidt2</dc:creator>
      <dc:date>2023-05-05T14:26:00Z</dc:date>
    </item>
  </channel>
</rss>

