<?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 Populate a field in the current record from the previous record in ArcGIS Field Maps Questions</title>
    <link>https://community.esri.com/t5/arcgis-field-maps-questions/populate-a-field-in-the-current-record-from-the/m-p/1158658#M2803</link>
    <description>&lt;P&gt;Hi.&amp;nbsp; Hopefully this is really simple and i'm missing something obvious.&amp;nbsp; Im using the latest fieldmaps with calculated expressions.&amp;nbsp; I have features with related records in the webmap and im creating smartforms for entering records.&amp;nbsp; I just want to grab one of the attributes from the previous record for that feature and populate a field in the new record.&amp;nbsp; The code below works but it uses the function FIRST so it grabs the first record.&amp;nbsp; I just want to grab the last, but everything i try gives an error.&amp;nbsp; This code works.&amp;nbsp; It just return the record from the wrong end of the featureset. Is there a "LAST" equivalent to "FIRST" that will work in calculated expressions?&lt;/P&gt;&lt;P&gt;//Recalls the most recent record for this feature and&lt;BR /&gt;//returns the BaitLeftAmount attribute&lt;/P&gt;&lt;P&gt;var recordGUID = $feature.GUID; //Grab the current GUID&lt;BR /&gt;var recordset = FeatureSetByName($map,'BaitRecords'); //Grab a featureset of records&lt;BR /&gt;var subset = filter(recordset,"Guid = @recordGUID" ); //filter down the featureset to just those with same GUID as this one&lt;BR /&gt;var oneline = &lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#800080"&gt;first&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;(orderby(subset,'DateChecked')); //takes only one line of the featureset&lt;BR /&gt;var baitamount = oneline.BaitLeftAmount; //takes only one attribute from the one line&lt;BR /&gt;return baitamount&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1138"&gt;@JeffShaner&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Mar 2022 01:19:50 GMT</pubDate>
    <dc:creator>Scott_Sambell</dc:creator>
    <dc:date>2022-03-29T01:19:50Z</dc:date>
    <item>
      <title>Populate a field in the current record from the previous record</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/populate-a-field-in-the-current-record-from-the/m-p/1158658#M2803</link>
      <description>&lt;P&gt;Hi.&amp;nbsp; Hopefully this is really simple and i'm missing something obvious.&amp;nbsp; Im using the latest fieldmaps with calculated expressions.&amp;nbsp; I have features with related records in the webmap and im creating smartforms for entering records.&amp;nbsp; I just want to grab one of the attributes from the previous record for that feature and populate a field in the new record.&amp;nbsp; The code below works but it uses the function FIRST so it grabs the first record.&amp;nbsp; I just want to grab the last, but everything i try gives an error.&amp;nbsp; This code works.&amp;nbsp; It just return the record from the wrong end of the featureset. Is there a "LAST" equivalent to "FIRST" that will work in calculated expressions?&lt;/P&gt;&lt;P&gt;//Recalls the most recent record for this feature and&lt;BR /&gt;//returns the BaitLeftAmount attribute&lt;/P&gt;&lt;P&gt;var recordGUID = $feature.GUID; //Grab the current GUID&lt;BR /&gt;var recordset = FeatureSetByName($map,'BaitRecords'); //Grab a featureset of records&lt;BR /&gt;var subset = filter(recordset,"Guid = @recordGUID" ); //filter down the featureset to just those with same GUID as this one&lt;BR /&gt;var oneline = &lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#800080"&gt;first&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;(orderby(subset,'DateChecked')); //takes only one line of the featureset&lt;BR /&gt;var baitamount = oneline.BaitLeftAmount; //takes only one attribute from the one line&lt;BR /&gt;return baitamount&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1138"&gt;@JeffShaner&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 01:19:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/populate-a-field-in-the-current-record-from-the/m-p/1158658#M2803</guid>
      <dc:creator>Scott_Sambell</dc:creator>
      <dc:date>2022-03-29T01:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Populate a field in the current record from the previous record</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/populate-a-field-in-the-current-record-from-the/m-p/1158663#M2804</link>
      <description>&lt;P&gt;I made this miasma that works by creating a variable that calculates the maximum ObjectID of the subset and then looks for the record with that ObjectID in the subset .&amp;nbsp; Not ideal, but it works and relies on ObjectIDs being sequential which is not always the case.&amp;nbsp; Still want to know what the opposite of FIRST is in Arcade.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var recordGUID = $feature.GUID;&amp;nbsp; //Grab the current GUID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var recordset = FeatureSetByName($map,'BaitRecords');&amp;nbsp; //Grab a featureset of records&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var subset = filter(recordset,"GUID = @recordGUID");&amp;nbsp; //filter down the featureset to just those with same GUID as this one&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var maxoid = max(subset,'OBJECTID'); //find the maximum ObjectID in the subset.&amp;nbsp; This would be a lot better if it was the maximum DateChecked but i can’t get that to work&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var subsubset = filter(subset, "OBJECTID = @maxoid")&amp;nbsp; //Just grab that one line that has the max objectID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var oneline = first(orderby(subsubset,'OBJECTID')); //takes only one line of the featureset.&amp;nbsp; Not sure why this is still necessary but it is&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var baitamount = oneline.BaitLeftAmount;&amp;nbsp; //takes only one attribute from the one line&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;return baitamount&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 02:18:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/populate-a-field-in-the-current-record-from-the/m-p/1158663#M2804</guid>
      <dc:creator>Scott_Sambell</dc:creator>
      <dc:date>2022-03-29T02:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Populate a field in the current record from the previous record</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/populate-a-field-in-the-current-record-from-the/m-p/1158856#M2813</link>
      <description>&lt;P&gt;I think you just need to add a "DESC" or "ASC" modifier to the order by clause to have the results sorted exactly how you want, then you can just get the first one. Like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;FIRST(ORDERBY(subset,'DateChecked DESC'))
FIRST(ORDERBY(subset,'DateChecked ASC'))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 14:22:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/populate-a-field-in-the-current-record-from-the/m-p/1158856#M2813</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-03-29T14:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: Populate a field in the current record from the previous record</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/populate-a-field-in-the-current-record-from-the/m-p/1159061#M2827</link>
      <description>&lt;P&gt;Hey Aaron.&amp;nbsp; Thats EXACTLY what it needed! Thank you so much.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 19:25:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/populate-a-field-in-the-current-record-from-the/m-p/1159061#M2827</guid>
      <dc:creator>Scott_Sambell</dc:creator>
      <dc:date>2022-03-29T19:25:17Z</dc:date>
    </item>
  </channel>
</rss>

