<?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 expression return nearest future date from FeatureSet in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1298537#M52760</link>
    <description>&lt;P&gt;If you're building a popup, you really ought to consider using an Arcade element, rather than returning a string. You are essentially building a fields list, so why not doing it directly? Under &lt;STRONG&gt;add content&lt;/STRONG&gt; in the popup menu, choose an Arcade element:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1686662978522.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/73027i964FCF005AD1E86C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1686662978522.png" alt="jcarlson_0-1686662978522.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The output of that code block will be a bit different, but it's not too hard. For the null situation, we can return a simple line of text, but we can bring your two desired attributes into a field list otherwise.&lt;/P&gt;&lt;P&gt;What happens when there are more than one items in the inspection dates table? The default sort is by objectid, so you may want to apply an OrderBy function before grabbing the first record, to ensure that you're really getting the latest item. An in response to one of your questions, would you have a situation in which there are multiple future inspection dates, and one is &lt;EM&gt;further &lt;/EM&gt;into the future? Without seeing the data, it's hard to know exactly how to approach the situation.&lt;/P&gt;&lt;P&gt;The first option would be to reverse the sort so that newer records are first:&lt;/P&gt;&lt;PRE&gt;fs = OrderBy(fs, 'lastinspdate DESC')&lt;/PRE&gt;&lt;P&gt;The other would be to filter out records where the "nextinspdate" field is in the past, and order by that field ascending, such that the first record will be the nearest future inspection date.&lt;/P&gt;&lt;PRE&gt;fs = Filter(OrderBy(fs, 'nextinspdate ASC'), 'nextinspdate &amp;gt; CURRENT_DATE()')&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;But once we have that figured out, the rest isn't too hard. When we have a feature returned by the filter, we can populate the popup item with a simple loop. Calling a loop on a Feature directly will iterate over its attributes, so there's no need to convert it to a dictionary first.&lt;/P&gt;&lt;PRE&gt;for (var attr in cou) {&lt;BR /&gt;  // do something per attribute&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;Anyway, we put this all together, and it might look like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Get inspection date records in Wo
var fs = FeatureSetByName(
  $map,
  "InspInspectionDates", 
  ['central_asset_id', 'lastinspdate', 'nextinspdate'],
  false
)

// Get future inspections, order for nearest to present
fs = Filter(OrderBy(fs, 'nextinspdate ASC'), 'nextinspdate &amp;gt; CURRENT_DATE()')

// Get the first
var cou = First(Filter(
  fs,
  `central_asset_id = '${$feature['CENTRAL_AS']}'`
))

// Return simple text if no inspection
if(cou == null) {
  return {
    type: 'text',
    text: 'No inspection found'
   }
}

// empty objects for output
var fieldInfos = []
var attributes = {}

for (var att in cou) {
  // push field name
  Push(fieldInfos, {fieldName: att})

  // add attribute
  attributes[att] = cou[att]
}

return {
  type: 'fields',
  title: 'Inspection Dates',
  fieldInfos: fieldInfos,
  attributes : attributes
}&lt;/LI-CODE&gt;&lt;P&gt;Now, if you wanted to go in and make those look a little nicer with field aliases, there's more you can do with the &lt;STRONG&gt;Schema &lt;/STRONG&gt;function, but the script above ought to be enough to get you a nice looking fields list in your popup.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jun 2023 13:48:43 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2023-06-13T13:48:43Z</dc:date>
    <item>
      <title>Arcade expression return nearest future date from FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1298510#M52759</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I am working on some code to bring across two date fields,&amp;nbsp;'&lt;SPAN&gt;lastinspdate' and 'nextinspdate' from another table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I've adapted some really useful code (below) to get me started (thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;) but I'm struggling to do two things:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1/ limit the response to just show the two date fields&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2/ to add in a filter that returns the response to the record with the 'nextinspdate' nearest in the future.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Many thanks in advance. Not a natural coder here so be kind &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;ref_id&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;$feature&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;"CENTRAL_AS"&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;fs&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;FeatureSetByName&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;$map&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"InspInspectionDates"&lt;/SPAN&gt;&lt;SPAN&gt;, [&lt;/SPAN&gt;&lt;SPAN&gt;'central_asset_id'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'lastinspdate'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'nextinspdate'&lt;/SPAN&gt;&lt;SPAN&gt;], &lt;/SPAN&gt;&lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;filt&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"central_asset_id = @ref_id"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;cou&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;First&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Filter&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;fs&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;filt&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;cou&lt;/SPAN&gt;&lt;SPAN&gt; == &lt;/SPAN&gt;&lt;SPAN&gt;null&lt;/SPAN&gt;&lt;SPAN&gt;) { &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;"No inspection found"&lt;/SPAN&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;attributes&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;Dictionary&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Text&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;cou&lt;/SPAN&gt;&lt;SPAN&gt;))[&lt;/SPAN&gt;&lt;SPAN&gt;"attributes"&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;popup_lines&lt;/SPAN&gt;&lt;SPAN&gt; = []&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;a&lt;/SPAN&gt; &lt;SPAN&gt;in&lt;/SPAN&gt; &lt;SPAN&gt;attributes&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;line&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;`&lt;/SPAN&gt;&lt;SPAN&gt;${&lt;/SPAN&gt;&lt;SPAN&gt;a&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;${&lt;/SPAN&gt;&lt;SPAN&gt;attributes&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;a&lt;/SPAN&gt;&lt;SPAN&gt;]}&lt;/SPAN&gt;&lt;SPAN&gt;`&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;Push&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;popup_lines&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;line&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;Concatenate&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;popup_lines&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;TextFormatting&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;NewLine&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 13 Jun 2023 13:13:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1298510#M52759</guid>
      <dc:creator>RingwayJacobs</dc:creator>
      <dc:date>2023-06-13T13:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression return nearest future date from FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1298537#M52760</link>
      <description>&lt;P&gt;If you're building a popup, you really ought to consider using an Arcade element, rather than returning a string. You are essentially building a fields list, so why not doing it directly? Under &lt;STRONG&gt;add content&lt;/STRONG&gt; in the popup menu, choose an Arcade element:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1686662978522.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/73027i964FCF005AD1E86C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1686662978522.png" alt="jcarlson_0-1686662978522.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The output of that code block will be a bit different, but it's not too hard. For the null situation, we can return a simple line of text, but we can bring your two desired attributes into a field list otherwise.&lt;/P&gt;&lt;P&gt;What happens when there are more than one items in the inspection dates table? The default sort is by objectid, so you may want to apply an OrderBy function before grabbing the first record, to ensure that you're really getting the latest item. An in response to one of your questions, would you have a situation in which there are multiple future inspection dates, and one is &lt;EM&gt;further &lt;/EM&gt;into the future? Without seeing the data, it's hard to know exactly how to approach the situation.&lt;/P&gt;&lt;P&gt;The first option would be to reverse the sort so that newer records are first:&lt;/P&gt;&lt;PRE&gt;fs = OrderBy(fs, 'lastinspdate DESC')&lt;/PRE&gt;&lt;P&gt;The other would be to filter out records where the "nextinspdate" field is in the past, and order by that field ascending, such that the first record will be the nearest future inspection date.&lt;/P&gt;&lt;PRE&gt;fs = Filter(OrderBy(fs, 'nextinspdate ASC'), 'nextinspdate &amp;gt; CURRENT_DATE()')&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;But once we have that figured out, the rest isn't too hard. When we have a feature returned by the filter, we can populate the popup item with a simple loop. Calling a loop on a Feature directly will iterate over its attributes, so there's no need to convert it to a dictionary first.&lt;/P&gt;&lt;PRE&gt;for (var attr in cou) {&lt;BR /&gt;  // do something per attribute&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;Anyway, we put this all together, and it might look like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Get inspection date records in Wo
var fs = FeatureSetByName(
  $map,
  "InspInspectionDates", 
  ['central_asset_id', 'lastinspdate', 'nextinspdate'],
  false
)

// Get future inspections, order for nearest to present
fs = Filter(OrderBy(fs, 'nextinspdate ASC'), 'nextinspdate &amp;gt; CURRENT_DATE()')

// Get the first
var cou = First(Filter(
  fs,
  `central_asset_id = '${$feature['CENTRAL_AS']}'`
))

// Return simple text if no inspection
if(cou == null) {
  return {
    type: 'text',
    text: 'No inspection found'
   }
}

// empty objects for output
var fieldInfos = []
var attributes = {}

for (var att in cou) {
  // push field name
  Push(fieldInfos, {fieldName: att})

  // add attribute
  attributes[att] = cou[att]
}

return {
  type: 'fields',
  title: 'Inspection Dates',
  fieldInfos: fieldInfos,
  attributes : attributes
}&lt;/LI-CODE&gt;&lt;P&gt;Now, if you wanted to go in and make those look a little nicer with field aliases, there's more you can do with the &lt;STRONG&gt;Schema &lt;/STRONG&gt;function, but the script above ought to be enough to get you a nice looking fields list in your popup.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 13:48:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1298537#M52760</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-06-13T13:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression return nearest future date from FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1298554#M52761</link>
      <description>&lt;P&gt;A general form could look like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// define which attributes to return
var return_attributes = ["lastinspdate", "nextinspdate"]

// load the featureset
var fs = FeatureSetByName($map, "InspInspectionDates", ['central_asset_id', 'lastinspdate', 'nextinspdate'], false)

// filter for id and dates in future
var ref_id = $feature["CENTRAL_AS"]
var dt = Now()
var filt = "central_asset_id = @ref_id AND nextinspdate &amp;gt; &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/92561"&gt;@DT&lt;/a&gt;"

// get the next future inspection date
var filtered_fs = OrderBy(Filter(fs, filt), "nextinspdate")
var cou = First(filtered_fs)
if(cou == null) { return "No future inspection found" }

var all_attributes = Dictionary(Text(cou))["attributes"]
var popup_lines = []
for(var a in return_attributes) {
    var att = return_attributes[a]
    var val = all_attributes[att]
    var line = `${att}: ${val}`
    Push(popup_lines, line)
}
return Concatenate(popup_lines, TextFormatting.NewLine)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is useful if you want to keep the expression expandable to include more/less fields later. If you don't need that, you can just hardcode it:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// define which attributes to return
var return_attributes = ["lastinspdate", "nextinspdate"]

// load the featureset
var fs = FeatureSetByName($map, "InspInspectionDates", ['central_asset_id', 'lastinspdate', 'nextinspdate'], false)

// filter for id and dates in future
var ref_id = $feature["CENTRAL_AS"]
var dt = Now()
var filt = "central_asset_id = @ref_id AND nextinspdate &amp;gt; &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/92561"&gt;@DT&lt;/a&gt;"

// get the next future inspection date
var filtered_fs = OrderBy(Filter(fs, filt), "nextinspdate")
var cou = First(filtered_fs)
if(cou == null) { return "No future inspection found" }

var popup_lines = [
    `Last inspection: ${cou["lastinspdate"]}`,
    `Next inspection: ${cou["nextinspdate"]}`,
]
return Concatenate(popup_lines, TextFormatting.NewLine)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 13 Jun 2023 14:09:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1298554#M52761</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-06-13T14:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression return nearest future date from FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1299061#M52801</link>
      <description>&lt;P&gt;Thanks for the super quick response Josh. I've taken your advice and used the Arcade block instead. I've used it before and its good, though I've found it leaves a messy blank space if you have a text bloc preceding it.&lt;/P&gt;&lt;P&gt;ESRI wasn't liking the Current_Date() part so I declared NOW() as a variable and replaced that bit.&lt;/P&gt;&lt;P&gt;Code now works but both yours and Johannes code are returning the if null text for all records so I'm not sure what is going on there...&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 09:37:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1299061#M52801</guid>
      <dc:creator>RingwayJacobs</dc:creator>
      <dc:date>2023-06-14T09:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression return nearest future date from FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1299062#M52802</link>
      <description>&lt;P&gt;Thanks for the really quick response Johannes. I like the idea of having the code expandable so the second option is definitely better.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reason though, its is returning the if null text for all records. I've tried changing&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/92561"&gt;@DT&lt;/a&gt; to @dt to see is that made any difference but it didn't. Also tried using Today() instead of Now().&lt;/P&gt;&lt;P&gt;There are definitely dates in the future in the source so not sure why they are not being picked up...&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 12:10:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1299062#M52802</guid>
      <dc:creator>RingwayJacobs</dc:creator>
      <dc:date>2023-06-14T12:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression return nearest future date from FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1299173#M52805</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;ESRI wasn't liking the Current_Date()&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You'd hope they would take it out of &lt;A href="https://doc.arcgis.com/en/arcgis-online/reference/sql-agol.htm" target="_blank" rel="noopener"&gt;their own documentation&lt;/A&gt;, then... Glad you fixed that part.&lt;/P&gt;&lt;P&gt;As for the nulls, try using &lt;STRONG&gt;IsEmpty()&lt;/STRONG&gt; instead? Or else, check for no-record situations before grabbing the &lt;STRONG&gt;cou &lt;/STRONG&gt;object. Swap this in for lines 12-24 in my code snipped above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var filt_fs = Filter(fs, `central_asset_id = '${$feature['CENTRAL_AS']}'`)

if (Count(filt_fs) &amp;lt; 1) {
  return {
    type: 'text',
    text: 'No inspection found'
   }
}

var cou = First(filt_fs)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 14:47:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1299173#M52805</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-06-14T14:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression return nearest future date from FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1299183#M52806</link>
      <description>&lt;P&gt;Hi Josh, thanks for coming back to me.&lt;/P&gt;&lt;P&gt;I've tried replacing line 19 with IsEmpty(cou) and IsEmpty('nextinspdate') and it doesn't like either. I just get "T&lt;SPAN&gt;est execution error: Invalid variable assignment.. Verify test data." as before&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When replacing 12-24 with your code, I get&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"Test execution error: Execution error - Cannot access value using a key of this type. Verify test data."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Not sure if you had any further ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 14:40:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1299183#M52806</guid>
      <dc:creator>RingwayJacobs</dc:creator>
      <dc:date>2023-06-14T14:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression return nearest future date from FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1299194#M52808</link>
      <description>&lt;P&gt;Ah, shoot. I forgot the "$" in front of "feature" in the filter statement. Editing my post.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 14:46:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1299194#M52808</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-06-14T14:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression return nearest future date from FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1299216#M52809</link>
      <description>&lt;P&gt;Ah that works better. I've also used&amp;nbsp;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;IsEmpty&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;filt_fs&lt;/SPAN&gt;&lt;SPAN&gt;)) { instead and now get the 'Inspection Dates' title coming up. Just no actual date info. Is there somewhere I need to declare that?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 15:07:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-return-nearest-future-date-from/m-p/1299216#M52809</guid>
      <dc:creator>RingwayJacobs</dc:creator>
      <dc:date>2023-06-14T15:07:48Z</dc:date>
    </item>
  </channel>
</rss>

