<?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: Arcade Generate new Unique ID for new record but not updating existing UID in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1234426#M49006</link>
    <description>&lt;P&gt;You have to check if the field is already filled at the start. If yes, just return that value.&lt;/P&gt;&lt;P&gt;Also, your rule can be simplified a bit:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// if this feature already has a fuid, return that
if(!IsEmpty($feature.FUID)) { return $feature.FUID }

// get the feature with the greatest fuid in the featureset
var fuid_features = Filter($featureset, "FUID IS NOT NULL")
var max_fuid_feature = First(OrderBy(fuid_features, "FUID DESC"))

// for an empty featureset, this will be null, so return the first fuid
if(max_fuid_feature == null) { return "EOC00001" }

// calculate and return the next fuid
var max_fuid = max_fuid_feature.FUID
var next_fuid_number = Number(Replace(max_fuid, "EOC", "")) + 1
return "EOC" + Text(next_fuid_number, "00000")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Nov 2022 08:37:11 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2022-11-23T08:37:11Z</dc:date>
    <item>
      <title>Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1234258#M49002</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I have the following Arcade code to create a new Unique ID on a feature layer (hosted on ArcGIS Server). It's working fine for a NEW record, but if I try to select an existing record, it will update the UID field with the next available number.&lt;/P&gt;&lt;P&gt;How can I avoid to overwrite an existing value? Thanks for any help you could provide.&lt;/P&gt;&lt;P&gt;D&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var fs=FeatureSetByName($datastore,'dr_testPts',['FUID'],false);
var cCurrentFUID = $feature.FUID


var fFilter = Filter(fs, 'FUID IS NOT NULL');
var fMax = 0
var tMax = 0
for (var k in fFilter){
    fMax = Max(Right(k.FUID, Count(k.FUID)-3))
    tMax = When(fMax&amp;gt;tMax,fMax, tMax)
}
tMax +=1
var vNewFUID = "EOC" + text(tMax, "00000")


if (IsEmpty(cCurrentFUID)){
    return vNewFUID
} else {
    return cCurrentFUID
}&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 22 Nov 2022 20:10:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1234258#M49002</guid>
      <dc:creator>DominicRobergeIADOT</dc:creator>
      <dc:date>2022-11-22T20:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1234426#M49006</link>
      <description>&lt;P&gt;You have to check if the field is already filled at the start. If yes, just return that value.&lt;/P&gt;&lt;P&gt;Also, your rule can be simplified a bit:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// if this feature already has a fuid, return that
if(!IsEmpty($feature.FUID)) { return $feature.FUID }

// get the feature with the greatest fuid in the featureset
var fuid_features = Filter($featureset, "FUID IS NOT NULL")
var max_fuid_feature = First(OrderBy(fuid_features, "FUID DESC"))

// for an empty featureset, this will be null, so return the first fuid
if(max_fuid_feature == null) { return "EOC00001" }

// calculate and return the next fuid
var max_fuid = max_fuid_feature.FUID
var next_fuid_number = Number(Replace(max_fuid, "EOC", "")) + 1
return "EOC" + Text(next_fuid_number, "00000")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 08:37:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1234426#M49006</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-11-23T08:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1234521#M49008</link>
      <description>&lt;P&gt;Hi Johannes&lt;/P&gt;&lt;P&gt;thanks for helping me on this.&amp;nbsp; I modified my expression accordingly and when I tried it in the web map.... nothing.... Then I decided to try it in the Field Maps app and it was working just fine (new record and updating existing record). I then tried to create and Experience Builder app to see how it would behave... same as web map, Empty FUID field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea why it's not working properly in the web map? For this project, my users will enter/modify data either through a web map or experience builder app.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DominicRoberge2_0-1669216898189.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/56700iA53AD40309A7C5E2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DominicRoberge2_0-1669216898189.png" alt="DominicRoberge2_0-1669216898189.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 15:24:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1234521#M49008</guid>
      <dc:creator>DominicRobergeIADOT</dc:creator>
      <dc:date>2022-11-23T15:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1234828#M49017</link>
      <description>&lt;P&gt;This looks as if you have not actually created the feature yet. The attribute rule doesn't&amp;nbsp; trigger when you put the point in, only when you finish the feature creation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the feature creation window: The FUID isn't there, because the rule didn't trigger yet.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1669276083269.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/56793i33FD5A2F9711A094/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1669276083269.png" alt="JohannesLindner_1-1669276083269.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After I clicked on "Hinzufügen" ("Add"): Now the rule did trigger, and the FUID is calculated.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_2-1669276156299.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/56794i5AA5E2964D096C43/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_2-1669276156299.png" alt="JohannesLindner_2-1669276156299.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 07:50:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1234828#M49017</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-11-24T07:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1234886#M49018</link>
      <description>&lt;P&gt;Thanks for the info. However when the expressio is enabled, I can't click the Create Feature button.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DominicRoberge2_0-1669298218027.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/56806i6C3121DF0476C942/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DominicRoberge2_0-1669298218027.png" alt="DominicRoberge2_0-1669298218027.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;when I test the expression it seems to be working&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DominicRoberge2_1-1669298284815.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/56807iC3C8F3FE9E39D6C6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DominicRoberge2_1-1669298284815.png" alt="DominicRoberge2_1-1669298284815.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;if I disable the expresssion, then I can Create&amp;nbsp; feature&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DominicRoberge2_2-1669298357264.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/56808iFCA8E805BC33E192/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DominicRoberge2_2-1669298357264.png" alt="DominicRoberge2_2-1669298357264.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I missing? I also tested the process on a different HFL and different web map and same result.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 14:08:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1234886#M49018</guid>
      <dc:creator>DominicRobergeIADOT</dc:creator>
      <dc:date>2022-11-24T14:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1234888#M49019</link>
      <description>&lt;P&gt;I'm sorry to say that I have no idea what could be the case.&lt;/P&gt;&lt;P&gt;Maybe&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/346994"&gt;@HusseinNasser2&lt;/a&gt;&amp;nbsp;can help?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 14:23:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1234888#M49019</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-11-24T14:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1240770#M49342</link>
      <description>&lt;P&gt;hello everyone&lt;/P&gt;&lt;P&gt;sorry it took so long, I had open a ticket with ESRI Support regarding this issue and they finally&amp;nbsp; created a BUG as they were able to replicate the issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Bug Number&lt;/STRONG&gt;:&amp;nbsp;BUG-000154427&lt;BR /&gt;&lt;STRONG&gt;Synopsis&lt;/STRONG&gt;:&amp;nbsp;The Arcade expression configured in a form within a web map does not get honored in Map Viewer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas how I could generate a unique ID automatically?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 20:22:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1240770#M49342</guid>
      <dc:creator>DominicRobergeIADOT</dc:creator>
      <dc:date>2022-12-13T20:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1275952#M51315</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/366436"&gt;@DominicRobergeIADOT&lt;/a&gt;&amp;nbsp;any updates on whether the bug was fixed?&amp;nbsp; I'm having the same issue in the form in the new map viewer.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 19:33:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1275952#M51315</guid>
      <dc:creator>DonSjoboen</dc:creator>
      <dc:date>2023-04-05T19:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1275957#M51316</link>
      <description>&lt;P&gt;this is all I got&lt;/P&gt;&lt;P&gt;Looks like is under review&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DominicRoberge2_0-1680723568515.png" style="width: 773px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/67367i9585B61378F59FB8/image-dimensions/773x309?v=v2" width="773" height="309" role="button" title="DominicRoberge2_0-1680723568515.png" alt="DominicRoberge2_0-1680723568515.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 19:40:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1275957#M51316</guid>
      <dc:creator>DominicRobergeIADOT</dc:creator>
      <dc:date>2023-04-05T19:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1277012#M51370</link>
      <description>&lt;P&gt;We are seeing a similar issue in one of our apps/maps. is there a way to +1 to your bug?!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 18:08:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1277012#M51370</guid>
      <dc:creator>VanessaSimps</dc:creator>
      <dc:date>2023-04-10T18:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1277957#M51417</link>
      <description>&lt;P&gt;I am not sure... I don't see a link to "share" that bug and when I search for that specific BUG on ESRI Support site, I get nothing....&lt;/P&gt;&lt;P&gt;Sorry. Perhaps you will have to open a ticket with support, mention this BUG number and that will help promote the issue?&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":crossed_fingers:"&gt;🤞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 19:09:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1277957#M51417</guid>
      <dc:creator>DominicRobergeIADOT</dc:creator>
      <dc:date>2023-04-12T19:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1285892#M51950</link>
      <description>&lt;P&gt;I believe this issue has been resolved with the latest update (&lt;A href="https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/go-beyond-the-smart-editor-using-smart-forms/" target="_blank"&gt;https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/go-beyond-the-smart-editor-using-smart-forms/&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;below is my revised code and not it's working as expected&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// Define the edit context so the value is only calculated when the feature is created
if ($editContext.editType == "INSERT") {
  // Lookup the value for the last created feature
  var last_feature = First(OrderBy($layer, 'FUID DESC'));
  // If the last value was empty write 1, otherwise add 1 to the value

  // calculate and return the next fuid
  var max_fuid = last_feature.FUID
  var next_fuid_number = Number(Replace(max_fuid, "EOC", "")) + 1
  return "EOC" + Text(next_fuid_number, "00000")

} else {
  // When the feature is updated, return the existing value in this field
  // and do not calculate a new value
  $feature.FUID
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 20:40:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1285892#M51950</guid>
      <dc:creator>DominicRobergeIADOT</dc:creator>
      <dc:date>2023-05-04T20:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1383582#M57531</link>
      <description>&lt;P&gt;I tried to set that code and edit but it won't let me create a new feature still either.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 19:26:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1383582#M57531</guid>
      <dc:creator>Laura</dc:creator>
      <dc:date>2024-02-16T19:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1492663#M59721</link>
      <description>&lt;P&gt;Any update on this bug? It's a bit concerning that Esri hasn't officially published this bug (or I just haven't been able to find it anywhere) and that they don't seem to be prioritizing this. I've tried the $editContext.editType version that someone else posted in this thread and that doesn't work either.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jan 2026 11:13:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1492663#M59721</guid>
      <dc:creator>BRENNEJM</dc:creator>
      <dc:date>2026-01-14T11:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Generate new Unique ID for new record but not updating existing UID</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1677783#M67598</link>
      <description>&lt;P&gt;It appears that Arcade is working as expected now (i.e. only creating the new Unique ID if that field is blank). Up until now we've been utilizing two maps (one for adding features and one for updating them) and it would be great to only need one map. Does anyone know if Esri acknowledged this as a bug and fixed it? If not, it seems like we'll need to stay with two maps just in case Arcade stops working as expected again.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jan 2026 11:13:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-generate-new-unique-id-for-new-record-but/m-p/1677783#M67598</guid>
      <dc:creator>BRENNEJM</dc:creator>
      <dc:date>2026-01-14T11:13:29Z</dc:date>
    </item>
  </channel>
</rss>

