<?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 Generate Sequential Asset IDs in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/auto-generate-sequential-asset-ids/m-p/560253#M43812</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This looks great, I will try.&lt;/P&gt;&lt;P&gt;Since its' a script, is there a way to execute it on new record creation?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Jul 2018 21:10:55 GMT</pubDate>
    <dc:creator>AndresCastillo</dc:creator>
    <dc:date>2018-07-06T21:10:55Z</dc:date>
    <item>
      <title>Auto Generate Sequential Asset IDs</title>
      <link>https://community.esri.com/t5/python-questions/auto-generate-sequential-asset-ids/m-p/560251#M43810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;TABLE style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-size: 13px; padding: 0px;"&gt;&lt;TBODY style="border: 0px; font-size: 13px; padding: 0px;"&gt;&lt;TR style="border: 0px; font-size: 13px; padding: 0px;"&gt;&lt;TD class="" style="border: 0px; font-size: 13px; padding: 0px 15px 0px 0px;"&gt;&lt;DIV class="" style="border: 0px; font-size: 13px; padding: 0px;"&gt;&lt;A class="" href="http://gis.stackexchange.com/questions/209251/auto-generate-sequential-asset-ids" style="color: #358daa; border: 0px; text-indent: -9999em; font-size: 1px; margin: 0px auto 2px; padding: 0px;" title="Click to mark as favorite question (click again to undo)"&gt;favorite&lt;/A&gt;&lt;DIV class="" style="border: 0px; font-size: 13px; padding: 0px;"&gt; &lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;TD class="" style="border: 0px; font-size: 13px; padding: 0px;"&gt;&lt;DIV style="border: 0px; font-size: 13px; padding: 0px;"&gt;&lt;DIV class="" style="border: 0px; margin: 0px 0px 5px; padding: 0px;"&gt;&lt;P style="border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;I am looking for a python script that will automatically assign a unique sequential value to a field every time a new feature (asset) is created. This ID will also need the abbreviated name prepended to the identifier.&lt;/P&gt;&lt;P style="border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;So for example, if I add a new sign (SN) to the signs feature class, I'd like that sign to have an Asset ID of SN235.&lt;/P&gt;&lt;P style="border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;Alternatively, I could field calculate each time a new asset or series of assets is added so long as the next feature is given the next sequential value.&lt;/P&gt;&lt;P style="border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;I have seen scripts such as this: &lt;A href="http://gis.stackexchange.com/questions/57300/how-can-you-auto-increment-in-a-python-script-not-field-calculator" style="color: #358daa; border: 0px; padding: 0px;"&gt;How can you auto-increment in a Python Script (not Field Calculator)?&lt;/A&gt;&lt;/P&gt;&lt;P style="border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;But it isn't quite what I need.&lt;/P&gt;&lt;P style="border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;Has anyone created or come across a script that will do this? Any insight on this is much appreciated!&lt;/P&gt;&lt;P style="border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;Thanks!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Sep 2016 19:53:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/auto-generate-sequential-asset-ids/m-p/560251#M43810</guid>
      <dc:creator>MitchellBate1</dc:creator>
      <dc:date>2016-09-01T19:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Generate Sequential Asset IDs</title>
      <link>https://community.esri.com/t5/python-questions/auto-generate-sequential-asset-ids/m-p/560252#M43811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Two quick ways off the top of my head: First, if the AssetID field isn't yet populated you could use a cursor to fill it in:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;prefix = 'SN'&lt;/P&gt;&lt;P&gt;with arcpy.da.UpdateCursor(file, ['AssetId']) as cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;for i, row in enumerate(cursor):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;row[0] = prefix + str(i)&lt;/P&gt;&lt;P&gt;&amp;nbsp;cursor.updateRow(row)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;prefix&lt;/EM&gt; could be a parameter from your tool interface, or output from a function which returns the first two letters of the feaure type, or anything else for that matter, I'll leave that up to you though &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If AssetID field is already populated and you're just filling it in for a new row:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;prefix = 'SN'&lt;/P&gt;&lt;P&gt;cursor =&amp;nbsp;arcpy.da.UpdateCursor(file, ['AssetId'])&amp;nbsp;&lt;/P&gt;&lt;P&gt;no_asset_id&amp;nbsp;= [r for r in cursor&amp;nbsp;if r[0] is None][0]&lt;/P&gt;&lt;P&gt;no_asset_id[0] = prefix + str(len(cursor))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cursor.updateRow(no_asset_id)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Sep 2016 23:01:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/auto-generate-sequential-asset-ids/m-p/560252#M43811</guid>
      <dc:creator>ClintonDow1</dc:creator>
      <dc:date>2016-09-01T23:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Generate Sequential Asset IDs</title>
      <link>https://community.esri.com/t5/python-questions/auto-generate-sequential-asset-ids/m-p/560253#M43812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This looks great, I will try.&lt;/P&gt;&lt;P&gt;Since its' a script, is there a way to execute it on new record creation?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jul 2018 21:10:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/auto-generate-sequential-asset-ids/m-p/560253#M43812</guid>
      <dc:creator>AndresCastillo</dc:creator>
      <dc:date>2018-07-06T21:10:55Z</dc:date>
    </item>
  </channel>
</rss>

