<?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 Arcade expression, Runtime error in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126882#M43421</link>
    <description>&lt;P&gt;I am attempting to create a pop-up in a web map that shows information from a table of Survey123 results.&lt;/P&gt;&lt;P&gt;We have a map of fuel tanks, which serves as the main layer I want users to be able to click on and see the pop-up. Our field staff fill out Survey123 forms with a repeat for each tank, recording how much fuel was filled. The feature class and the table are related by a tankID field, in a one-to-many relationship. Not every tank has received a fill yet, so not every record in the layer has a match in the table.&lt;/P&gt;&lt;P&gt;Below is the expression I am trying to make work. This puts out an error, "&lt;SPAN class=""&gt;Execution Error:&lt;/SPAN&gt;Runtime Error: Cannot call member property on object of this type. fuelFilled"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var layerID = $feature.tankID

var formID = FeatureSetByName($map,"TankFillRecord")

var filterStatement = "tankID = @layerID"

var tank = filter(formID, filterStatement)

return tank.fuelFilled&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideally, when this is working the expression will return the value of the fuelFilled field in the pop-up.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Dec 2021 19:42:39 GMT</pubDate>
    <dc:creator>Claudio_Verina</dc:creator>
    <dc:date>2021-12-16T19:42:39Z</dc:date>
    <item>
      <title>Arcade expression, Runtime error</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126882#M43421</link>
      <description>&lt;P&gt;I am attempting to create a pop-up in a web map that shows information from a table of Survey123 results.&lt;/P&gt;&lt;P&gt;We have a map of fuel tanks, which serves as the main layer I want users to be able to click on and see the pop-up. Our field staff fill out Survey123 forms with a repeat for each tank, recording how much fuel was filled. The feature class and the table are related by a tankID field, in a one-to-many relationship. Not every tank has received a fill yet, so not every record in the layer has a match in the table.&lt;/P&gt;&lt;P&gt;Below is the expression I am trying to make work. This puts out an error, "&lt;SPAN class=""&gt;Execution Error:&lt;/SPAN&gt;Runtime Error: Cannot call member property on object of this type. fuelFilled"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var layerID = $feature.tankID

var formID = FeatureSetByName($map,"TankFillRecord")

var filterStatement = "tankID = @layerID"

var tank = filter(formID, filterStatement)

return tank.fuelFilled&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideally, when this is working the expression will return the value of the fuelFilled field in the pop-up.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 19:42:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126882#M43421</guid>
      <dc:creator>Claudio_Verina</dc:creator>
      <dc:date>2021-12-16T19:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression, Runtime error</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126884#M43422</link>
      <description>&lt;P&gt;The Filter function returns either a FeatureSet or Array. Assuming the filter returns just one item, you should use&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;return tank[0].fuelFilled&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 19:54:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126884#M43422</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-12-16T19:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression, Runtime error</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126897#M43423</link>
      <description>&lt;P&gt;When I try this I still get "Runtime Error: Cannot call member property on object of this type."&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 20:12:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126897#M43423</guid>
      <dc:creator>Claudio_Verina</dc:creator>
      <dc:date>2021-12-16T20:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression, Runtime error</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126900#M43424</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp; has the right approach for an Array, but do be aware that FeatureSet objects cannot be accessed that way.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1639684819881.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/29884i2A1AC89BAAF00A74/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1639684819881.png" alt="jcarlson_0-1639684819881.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For a FeatureSet, you'll want to use &lt;STRONG&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#first" target="_self"&gt;First&lt;/A&gt;, &lt;/STRONG&gt;which returns the first Feature from the set.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_1-1639684888811.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/29885i7A381F1105D23C6E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_1-1639684888811.png" alt="jcarlson_1-1639684888811.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You'll want to consider, though, whether or not multiple values may be returned by your filter, and how to handle cases where there are &lt;EM&gt;no&lt;/EM&gt; records in the related table. Try something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var layerID = $feature.tankID

var formID = FeatureSetByName($map, "TankFillRecord")

var filterStatement = "tankID = @layerID"

// Filter for matching tank ID
var tanks = Filter(formID, filterStatement)

// Check if records exist, return default response if not
if (Count(tanks) == 0){
    return "No fill records yet."
} else {
    // Order records by objectid; you can set this to some date field, too
    var ordered_tanks = OrderBy(tanks, "objectid DESC")
    var tank = First(ordered_tanks)
    return tank.fuelFilled
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 20:17:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126900#M43424</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-12-16T20:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression, Runtime error</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126911#M43425</link>
      <description>&lt;P&gt;Thank you, this works and returns the expected value! However, I need to retrieve the last fill on each tank, and First() returns the earliest date when using OrderBy().&lt;/P&gt;&lt;P&gt;I tried using First(Reverse(ordered_tanks)) but that gave me an Invalid Parameter error.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 20:37:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126911#M43425</guid>
      <dc:creator>Claudio_Verina</dc:creator>
      <dc:date>2021-12-16T20:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression, Runtime error</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126916#M43427</link>
      <description>&lt;P&gt;So, that's where we'll need to look at other ways of ordering your records. If you have a date field, try something like:&lt;/P&gt;&lt;PRE&gt;var ordered_tanks = OrderBy(tanks, "some-date-field DESC")&lt;/PRE&gt;&lt;P&gt;That should get the most recent records to the top, and First will grab the latest one.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 20:45:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126916#M43427</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-12-16T20:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression, Runtime error</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126920#M43429</link>
      <description>&lt;P&gt;That did it, thank you very much!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 20:49:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-runtime-error/m-p/1126920#M43429</guid>
      <dc:creator>Claudio_Verina</dc:creator>
      <dc:date>2021-12-16T20:49:06Z</dc:date>
    </item>
  </channel>
</rss>

