<?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: Calculated Expression - return OBJECTID in ArcGIS Field Maps Questions</title>
    <link>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1244412#M5090</link>
    <description>&lt;P&gt;I know this is an old question, but I thought I'd provide an answer in case anyone else needs it. The following code worked for me to make a facility id field using objectid:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;var fs_data = FeatureSetByName($datastore, "Example_Data", ["OBJECTID"], false)
var id = max(fs_data, "OBJECTID")
id = id + 1
var string_id = text(id)
var fid = concatenate("F-", string_id)
return fid&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this works for anyone else who needs it!&lt;/P&gt;</description>
    <pubDate>Thu, 29 Dec 2022 21:34:25 GMT</pubDate>
    <dc:creator>MarkBennett</dc:creator>
    <dc:date>2022-12-29T21:34:25Z</dc:date>
    <item>
      <title>Calculated Expression - return OBJECTID</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1158543#M2797</link>
      <description>&lt;P&gt;I understand calculated expressions are a fresh (and brilliant addition) to Field Maps, but should it be possible to automatically retrieve the objectid of the feature and use it to populate a field?&lt;/P&gt;&lt;P&gt;My use case is that I want to assign a unique reference to each newly created feature with a concat of text and the objectid. I'm testing at the moment and I am only able to calculate the text part. Interestingly, when I submit the form, I can see that output of what I am after appears briefly during the submission of the form(suggesting to me that objectid has been retrieved), but it doesn't actually calculate the field with the full concat.&lt;/P&gt;&lt;P&gt;TIA&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 19:40:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1158543#M2797</guid>
      <dc:creator>RonParis</dc:creator>
      <dc:date>2022-03-28T19:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Expression - return OBJECTID</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1158765#M2807</link>
      <description>&lt;P&gt;I just tried it myself and it seems like it works. It would be something like:&lt;/P&gt;&lt;P&gt;var NewField = concatenate(['Text ',feature.ObjectID]);&lt;/P&gt;&lt;P&gt;return NewField&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 11:43:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1158765#M2807</guid>
      <dc:creator>DamonBreen</dc:creator>
      <dc:date>2022-03-29T11:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Expression - return OBJECTID</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1158783#M2810</link>
      <description>&lt;P&gt;Thanks Damon, but this still doesn't work unfortunately. I have tried the following:&lt;/P&gt;&lt;PRE&gt;var NewField = concatenate(['Text',$feature.OBJECTID]);&lt;BR /&gt;&lt;BR /&gt;return NewField&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;and&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;"Text" + $feature.OBJECTID&lt;/PRE&gt;&lt;P&gt;In both instances, I can still see the correct output showing briefly when the form is submitting.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 12:30:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1158783#M2810</guid>
      <dc:creator>RonParis</dc:creator>
      <dc:date>2022-03-29T12:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Expression - return OBJECTID</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1158799#M2812</link>
      <description>&lt;P&gt;I saw that it worked in the expression builder and went with it. My assumption is that upon creation of a new feature, the ObjectID may not be created until the form is submitted. If that is the case, and what is causing the problem, you could reference the LAST ObjectID and add 1 to it. This may be problematic if you delete features from the map however.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 12:50:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1158799#M2812</guid>
      <dc:creator>DamonBreen</dc:creator>
      <dc:date>2022-03-29T12:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Expression - return OBJECTID</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1158872#M2817</link>
      <description>&lt;P&gt;That was my thoughts also regarding the allocation of the objectid, but I notice that when I press submit and the submission is taking place, the concat of the text and the objectid does appear for a split second in it's correct form. Not sure if it's a bug or the functionality just isn't there&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 14:58:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1158872#M2817</guid>
      <dc:creator>RonParis</dc:creator>
      <dc:date>2022-03-29T14:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Expression - return OBJECTID</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1158893#M2820</link>
      <description>&lt;P&gt;You're probably right in thinking it's a bug. I saw Thursday where they have actually pulled the full functionality of the calculated expressions because of&amp;nbsp; a "Show Stopper" error. It may just be that something is broken, because this is the third time now where I have made a calculated expression, and the test button in the expression builder shows it is working, but when I real world test it, it does not work. I was able to get the most recent idea I explained to work, but when I sort the globalID's of the previous records, I can only get it to pull the first record, and not the last. Not sure what kind of command I need to use to reverse it for it to do what you're trying to do, but this is what I came up with. Maybe you can finish it off.&lt;/P&gt;&lt;P&gt;var AllRecords = FeatureSetByName($map, "Odorizer");// pull all record of the 'Odorizer' feature&lt;BR /&gt;var LastObjectID = Top(OrderBy(AllRecords, "ObjectID"),1);// sort all pulled records by ObjectID&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if (IsEmpty(AllRecords)) { // if there are no previous records...&lt;BR /&gt;return '1'; // then this must be the first, so the ObjectID should be 1&lt;BR /&gt;} else {&lt;BR /&gt;for (var Rec in LastObjectID){ // loops through to the only record&lt;BR /&gt;var LastRecord = Rec.ObjectID //gets the objectID of the only record&lt;BR /&gt;var CurrentObjectID = LastRecord +1 // adds 1 to the ObjectID of the last record&lt;BR /&gt;&lt;BR /&gt;concatenate("Text ", CurrentObjectID); //concatenates text with what should be the current GlobalID&lt;BR /&gt;return CurrentObjectID; // return value&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 15:30:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1158893#M2820</guid>
      <dc:creator>DamonBreen</dc:creator>
      <dc:date>2022-03-29T15:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Expression - return OBJECTID</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1192807#M4111</link>
      <description>&lt;P&gt;This post is useful — thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've read that it's not a good idea to use Object ID as a bases to generate unquie IDs.&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;This is a cardinal rule! Never use any internal IDs from a geodatabase or any other database for your unique IDs unless you are 100% certain that it will not be automatically recalculated by the application in the future. An example of this is the OBJECTID attribute in a geodatabase. Because the OBJECTID attribute is internally used by the geodatabase, on occasion in may be recalculated by ArcMap.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thoughts/opinions on this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 05:57:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1192807#M4111</guid>
      <dc:creator>NickShannon2</dc:creator>
      <dc:date>2022-07-18T05:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Expression - return OBJECTID</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1244412#M5090</link>
      <description>&lt;P&gt;I know this is an old question, but I thought I'd provide an answer in case anyone else needs it. The following code worked for me to make a facility id field using objectid:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;var fs_data = FeatureSetByName($datastore, "Example_Data", ["OBJECTID"], false)
var id = max(fs_data, "OBJECTID")
id = id + 1
var string_id = text(id)
var fid = concatenate("F-", string_id)
return fid&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this works for anyone else who needs it!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2022 21:34:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/calculated-expression-return-objectid/m-p/1244412#M5090</guid>
      <dc:creator>MarkBennett</dc:creator>
      <dc:date>2022-12-29T21:34:25Z</dc:date>
    </item>
  </channel>
</rss>

