<?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 Concatenate in Calculated Field not functioning in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/concatenate-in-calculated-field-not-functioning/m-p/1398243#M6990</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am trying to come up with a code to auto-generate ID code using the calculated field in fieldmap designer/form. The ID should have the format "Alpha Code_Year_Serial Number". The serial number will restart every year. I was able to accomplish this by adding three different fields and combining them in ID with this code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Concatenate([$feature.AlphaCode, Text($feature.YearID), Text($feature.SerNum)], '_')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However, I really want to make it a single field thing where I can just calculate it within "NestID" only (without the need to create YearID and Serial number field). I have attempted with the code below, I have tested each part individually and I am stuck with the concatenate function doesn't seem to work.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var timestam = Today()
var currentyear = Text(timestam, 'YY')

var currentFeature = $feature["NestID"]
if (IsEmpty(currentFeature)) {
var features = FeatureSetByName($map,'Nest Location', ['NestID','YearID', 'AlphaCode', 'SurveyDate'], true);
var Year = Text($feature["SurveyDate"], 'YY')
var features2024 = Filter(features, 'YearID = @currentyear')
var countOfFeatures = Count(features2024);
if(countOfFeatures == 0) {

return Concatenate([$feature.AlphaCode, Text($feature.YearID), Text($feature.SerNum)], '_')
}
else
{

return Concatenate([$feature.AlphaCode, Text($feature.YearID), Text($feature.SerNum)], '_')
}
}
else

return $feature["NestID"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When I hit the test, it ran fine showing me a result (first ID that already existed in my database). However, when I tested it in the field map, none of the text would show up after I filled in the survey date and Alpha Code(only showing "__"). I wonder if anyone can find bugs in the code. Thank you in advanced!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Mar 2024 02:58:54 GMT</pubDate>
    <dc:creator>HelenLin</dc:creator>
    <dc:date>2024-03-20T02:58:54Z</dc:date>
    <item>
      <title>Concatenate in Calculated Field not functioning</title>
      <link>https://community.esri.com/t5/developers-questions/concatenate-in-calculated-field-not-functioning/m-p/1398243#M6990</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am trying to come up with a code to auto-generate ID code using the calculated field in fieldmap designer/form. The ID should have the format "Alpha Code_Year_Serial Number". The serial number will restart every year. I was able to accomplish this by adding three different fields and combining them in ID with this code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Concatenate([$feature.AlphaCode, Text($feature.YearID), Text($feature.SerNum)], '_')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However, I really want to make it a single field thing where I can just calculate it within "NestID" only (without the need to create YearID and Serial number field). I have attempted with the code below, I have tested each part individually and I am stuck with the concatenate function doesn't seem to work.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var timestam = Today()
var currentyear = Text(timestam, 'YY')

var currentFeature = $feature["NestID"]
if (IsEmpty(currentFeature)) {
var features = FeatureSetByName($map,'Nest Location', ['NestID','YearID', 'AlphaCode', 'SurveyDate'], true);
var Year = Text($feature["SurveyDate"], 'YY')
var features2024 = Filter(features, 'YearID = @currentyear')
var countOfFeatures = Count(features2024);
if(countOfFeatures == 0) {

return Concatenate([$feature.AlphaCode, Text($feature.YearID), Text($feature.SerNum)], '_')
}
else
{

return Concatenate([$feature.AlphaCode, Text($feature.YearID), Text($feature.SerNum)], '_')
}
}
else

return $feature["NestID"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When I hit the test, it ran fine showing me a result (first ID that already existed in my database). However, when I tested it in the field map, none of the text would show up after I filled in the survey date and Alpha Code(only showing "__"). I wonder if anyone can find bugs in the code. Thank you in advanced!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 02:58:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/concatenate-in-calculated-field-not-functioning/m-p/1398243#M6990</guid>
      <dc:creator>HelenLin</dc:creator>
      <dc:date>2024-03-20T02:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate in Calculated Field not functioning</title>
      <link>https://community.esri.com/t5/developers-questions/concatenate-in-calculated-field-not-functioning/m-p/1398284#M6991</link>
      <description>&lt;P&gt;Your concatenate is still looking for fields named "AlphaCode", "YearID and "SerNum".&lt;BR /&gt;&lt;BR /&gt;You need to change your concatenate to reference the variables you've cast in your earlier code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unsure what format you want your serial number to take. You can always pad it with leading zeros, but something like this as a starter for 10?:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Concatenate([$feature.AlphaCode, Year, Text(countOfFeatures)], '_')&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 20 Mar 2024 09:19:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/concatenate-in-calculated-field-not-functioning/m-p/1398284#M6991</guid>
      <dc:creator>RichardHowe</dc:creator>
      <dc:date>2024-03-20T09:19:46Z</dc:date>
    </item>
  </channel>
</rss>

