<?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: Use database sequence function from AGOL layer/table to generate unique integer IDs? in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/use-database-sequence-function-from-agol-layer/m-p/1699825#M68600</link>
    <description>&lt;P&gt;I'm not sure if this would be an acceptable solution for you, but you might be able to do that through AGOL Notebooks. You'd be able to define your own SQL expression to calculate the Unique ID in the format you are needing. The downside is that the calculation wouldn't be immediate. The AGOL Notebook would run either on demand or on a schedule.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-online-questions/auto-calculate-unique-id-in-hosted-feature-service/td-p/1153764" target="_blank"&gt;https://community.esri.com/t5/arcgis-online-questions/auto-calculate-unique-id-in-hosted-feature-service/td-p/1153764&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Attribute rules would be a good solution, but that only works on ArcGIS Enterprise and not AGOL unfortunately.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 May 2026 13:50:57 GMT</pubDate>
    <dc:creator>RyanUthoff</dc:creator>
    <dc:date>2026-05-04T13:50:57Z</dc:date>
    <item>
      <title>Use database sequence function from AGOL layer/table to generate unique integer IDs?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/use-database-sequence-function-from-agol-layer/m-p/1699767#M68590</link>
      <description>&lt;P&gt;It’s possible to automatically populate the default value of an AGOL hosted feature layer GUID field using&amp;nbsp;&lt;FONT face="courier new,courier" color="#0000FF"&gt;NEWID() WITH VALUES&lt;/FONT&gt;, using the Admin REST API.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-online-questions/add-guid-field-to-existing-agol-survey123-feature/m-p/1698411/highlight/true#M68519" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/arcgis-online-questions/add-guid-field-to-existing-agol-survey123-feature/m-p/1698411/highlight/true#M68519&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to do something similar, but instead of populating a GUID field, populate a sequential integer in a number field? (Or a textual ID with a prefix like SEWER-0000001 ?)&lt;/P&gt;&lt;P&gt;For example, is there a function similar to NEWID() that gets the next available integer for the layer/table from a database sequence?&lt;/P&gt;&lt;P&gt;An integer would be preferable over a GUID because it’s shorter and human-readable. All of our other asset IDs are integers or text-integer format, not GUIDs.&lt;/P&gt;</description>
      <pubDate>Sun, 03 May 2026 23:40:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/use-database-sequence-function-from-agol-layer/m-p/1699767#M68590</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2026-05-03T23:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Use database sequence function from AGOL layer/table to generate unique integer IDs?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/use-database-sequence-function-from-agol-layer/m-p/1699768#M68591</link>
      <description>&lt;P&gt;Would someone with DBA privileges in an on-prem Portal datastore database be able to poke around in a table to see if there are any database sequences used that would also be available in AGOL?&lt;/P&gt;&lt;P&gt;(This is more of an “out of curiosity” thing to see if we can learn anything interesting, not necessarily something that should be done in a mission-critical AGOL feature layer without testing.)&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2026 00:00:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/use-database-sequence-function-from-agol-layer/m-p/1699768#M68591</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2026-05-04T00:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: Use database sequence function from AGOL layer/table to generate unique integer IDs?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/use-database-sequence-function-from-agol-layer/m-p/1699825#M68600</link>
      <description>&lt;P&gt;I'm not sure if this would be an acceptable solution for you, but you might be able to do that through AGOL Notebooks. You'd be able to define your own SQL expression to calculate the Unique ID in the format you are needing. The downside is that the calculation wouldn't be immediate. The AGOL Notebook would run either on demand or on a schedule.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-online-questions/auto-calculate-unique-id-in-hosted-feature-service/td-p/1153764" target="_blank"&gt;https://community.esri.com/t5/arcgis-online-questions/auto-calculate-unique-id-in-hosted-feature-service/td-p/1153764&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Attribute rules would be a good solution, but that only works on ArcGIS Enterprise and not AGOL unfortunately.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2026 13:50:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/use-database-sequence-function-from-agol-layer/m-p/1699825#M68600</guid>
      <dc:creator>RyanUthoff</dc:creator>
      <dc:date>2026-05-04T13:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: Use database sequence function from AGOL layer/table to generate unique integer IDs?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/use-database-sequence-function-from-agol-layer/m-p/1699852#M68604</link>
      <description>&lt;P&gt;This is the arcade code that comes with the sign solution I just deployed, but it requires edits be made in a web map or app, not really on the data directly like an attribute rule would. This is added in the Form Editor of the web map.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var layerIndex = '0'&lt;BR /&gt;var idField = 'assetid'&lt;BR /&gt;var idPrefix = 'SIGN-'&lt;BR /&gt;var digits = 6&lt;/P&gt;&lt;P&gt;/*DO NOT CHANGE ANYTHING BELOW THIS LINE&lt;BR /&gt;-------------------------------------------------------------------------*/&lt;/P&gt;&lt;P&gt;function GenerateWildcards(digits, wildcard) {&lt;BR /&gt;var wildcards = ''&lt;BR /&gt;for (var i=0; i &amp;lt; digits; i++) {&lt;BR /&gt;wildcards += wildcard&lt;BR /&gt;}&lt;BR /&gt;return wildcards&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;function GetNextId(layerIndex, idField, idPrefix, padding, sqlFilter) {&lt;BR /&gt;// get the feature with the greatest assetid that matches the id pattern specified in the SQL statement.&lt;BR /&gt;var assetid_features = Filter(FeatureSetById($datastore, layerIndex, [idField], false), sqlFilter)&lt;BR /&gt;var max_assetid_feature = First(OrderBy(assetid_features, `${idField} DESC`))&lt;/P&gt;&lt;P&gt;// If no features match the pattern the featureset will be null, return the first assetid&lt;BR /&gt;if(max_assetid_feature == null) {&lt;BR /&gt;return `${idPrefix}${Right(padding, Count(padding)-1)}1`&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// when features do match the pattern calculate and return the next assetid&lt;BR /&gt;var max_assetid = max_assetid_feature[idField]&lt;BR /&gt;&lt;BR /&gt;var next_assetid_number = Number(Replace(max_assetid, idPrefix, "")) + 1&lt;BR /&gt;return `${idPrefix}${Text(next_assetid_number, padding)}`&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Define the edit context so the value is only calculated when the feature is created&lt;BR /&gt;if ($editContext.editType == "INSERT") {&lt;BR /&gt;// return matching prefix pattern and get next value&lt;BR /&gt;var wildcards = GenerateWildcards(digits, '_')&lt;BR /&gt;var padding = GenerateWildcards(digits, '0')&lt;BR /&gt;if (idPrefix != '') {&lt;BR /&gt;var sqlFilter = `${idField} LIKE '${idPrefix}${wildcards}' AND ${idField} NOT LIKE '%[^0-9]'`&lt;BR /&gt;GetNextId(layerIndex, idField, idPrefix, padding, sqlFilter)&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// return number id's only and get next value&lt;BR /&gt;else {&lt;BR /&gt;var sqlFilter = `${idField} NOT LIKE '%[^0-9.]%'`&lt;BR /&gt;GetNextId(layerIndex, idField, idPrefix, padding, sqlFilter)&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;else {&lt;BR /&gt;return $feature[idField]&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2026 18:21:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/use-database-sequence-function-from-agol-layer/m-p/1699852#M68604</guid>
      <dc:creator>snowdrop7934</dc:creator>
      <dc:date>2026-05-04T18:21:13Z</dc:date>
    </item>
  </channel>
</rss>

