<?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: Field calculation FeatureSet function failing within iOS mobile platform in ArcGIS Field Maps Questions</title>
    <link>https://community.esri.com/t5/arcgis-field-maps-questions/field-calculation-featureset-function-failing/m-p/1159984#M2849</link>
    <description>&lt;P&gt;My guess would be a memory issue.&amp;nbsp; It does work on iOS I use it a lot.&amp;nbsp; Other one to watch out for is if you are offline the lookup records need to be offline also.&lt;/P&gt;&lt;P&gt;You can reduce memory and improve speed with some code changes.&amp;nbsp; I would also use map not datastore.&lt;/P&gt;&lt;P&gt;FeatureSet lets you ask for just 1 field&amp;nbsp;['CollectCoreSubset1'] and not send back geometry, the false part, since you do not need it.&lt;/P&gt;&lt;P&gt;FeatureSetByName($map,"Points", ['CollectCoreSubset1'], false)&lt;/P&gt;&lt;P&gt;I think you have some logic issues here also with the double return - this could be causing it to return null and cause issues.&amp;nbsp; I shorted a bit and return "" instead.&amp;nbsp; I use the dot notion on fields.&amp;nbsp; Note you can pick any field I just picked gloablid in the related table.&amp;nbsp; Also the last step not sure that related field is in the related table or just the parent.&amp;nbsp; Either way you already know it so no need to read the table value.&lt;/P&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;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var activitysql = "GlobalID = '" + $feature.related_global_id" + "'";//create sql expression to filter activity records feature set

var activitytbl = FeatureSetByName($map,"Tree Activity", ['GlobalID'], false); //access tree activity table

var activityrecords = Filter(activitytbl, activitysql);//isolate related activity record(s)


if (Count(activityrecords) == 0) {
  return ""
} 
else {
    return $feature.related_global_id;
}&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that works&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jun 2022 19:37:16 GMT</pubDate>
    <dc:creator>DougBrowning</dc:creator>
    <dc:date>2022-06-28T19:37:16Z</dc:date>
    <item>
      <title>Field calculation FeatureSet function failing within iOS mobile platform</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/field-calculation-featureset-function-failing/m-p/1159897#M2846</link>
      <description>&lt;P&gt;Is anyone else having any trouble with this? Creating an expression that uses a featureset (by ID or by name) fails to run properly on iOS devices. It does however, run properly on Android. Here's the beginning of a code that I was working on:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var  activityid = $feature["related_global_id"]; //pull activity id from current related record attribute

var activitysql = "GlobalID = '" + activityid + "'";//create sql expression to filter activity records feature set

var activitytbl = FeatureSetByName($datastore,"Tree Activity"); //access tree activity table

var activityrecords = Filter(activitytbl, activitysql);//isolate related activity record(s)

var activitycnt = Count(activityrecords);//count the number of records returned after filtering

var activity = First(activityrecords);

var treeid = "";

if (activitycnt == 0) {
  return null;
} else {
    treeid = activity.related_global_id;
}

return treeid&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;'treeid' returns properly on android but not our ipad.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 14:53:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/field-calculation-featureset-function-failing/m-p/1159897#M2846</guid>
      <dc:creator>ajevans429</dc:creator>
      <dc:date>2022-03-31T14:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation FeatureSet function failing within iOS mobile platform</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/field-calculation-featureset-function-failing/m-p/1159984#M2849</link>
      <description>&lt;P&gt;My guess would be a memory issue.&amp;nbsp; It does work on iOS I use it a lot.&amp;nbsp; Other one to watch out for is if you are offline the lookup records need to be offline also.&lt;/P&gt;&lt;P&gt;You can reduce memory and improve speed with some code changes.&amp;nbsp; I would also use map not datastore.&lt;/P&gt;&lt;P&gt;FeatureSet lets you ask for just 1 field&amp;nbsp;['CollectCoreSubset1'] and not send back geometry, the false part, since you do not need it.&lt;/P&gt;&lt;P&gt;FeatureSetByName($map,"Points", ['CollectCoreSubset1'], false)&lt;/P&gt;&lt;P&gt;I think you have some logic issues here also with the double return - this could be causing it to return null and cause issues.&amp;nbsp; I shorted a bit and return "" instead.&amp;nbsp; I use the dot notion on fields.&amp;nbsp; Note you can pick any field I just picked gloablid in the related table.&amp;nbsp; Also the last step not sure that related field is in the related table or just the parent.&amp;nbsp; Either way you already know it so no need to read the table value.&lt;/P&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;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var activitysql = "GlobalID = '" + $feature.related_global_id" + "'";//create sql expression to filter activity records feature set

var activitytbl = FeatureSetByName($map,"Tree Activity", ['GlobalID'], false); //access tree activity table

var activityrecords = Filter(activitytbl, activitysql);//isolate related activity record(s)


if (Count(activityrecords) == 0) {
  return ""
} 
else {
    return $feature.related_global_id;
}&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that works&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 19:37:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/field-calculation-featureset-function-failing/m-p/1159984#M2849</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2022-06-28T19:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: Field calculation FeatureSet function failing within iOS mobile platform</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/field-calculation-featureset-function-failing/m-p/1160216#M2855</link>
      <description>&lt;P&gt;Wow, thanks for the tips! Although the way you rewrote it wasn't exactly what I was trying to accomplish, you helped me narrow down the issue. It seems like the iOS app won't process the 'FeatureSet($datasore,...' scenario, but 'FeatureSet($map,...' works just fine. It's interesting to note that the former (datastore) works just fine when used within the Android app. We are not working offline at this time, btw.&lt;/P&gt;&lt;P&gt;Here's my full code below. Just to add: I'm trying to access the attributes of a parent feature that's twice removed (tree site -&amp;gt; tree activity -&amp;gt; risk assessment form). The 'risk assessment form' is the one I am trying to apply this expression to. Feel free to reply with any other suggestions for cleanup!&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var activitysql = "GlobalID = '" + $feature.related_global_id + "'";//create sql expression to filter activity records feature set

var activitytbl = FeatureSetById($map, /* Tree Activity */ "Forestry_Tree_Sites_4869", ['GlobalID','related_global_id'], false); //access tree activity table

var activityrecords = Filter(activitytbl, activitysql);//isolate related activity records

var activity = First(activityrecords); //isolate the individual record

var treegid = ""; //initiate a variable to hold result

if (Count(activityrecords) == 0) {
  return ""
} 
else {
    treegid = activity.related_global_id;
}

var treesitesql = "GlobalID = '" + treegid + "'";//create sql expression to filter 'tree site' records

var treesitetbl = FeatureSetById($map, /* Forestry Tree Sites */ "Forestry_Tree_Sites_2068", ['GlobalID','latin_genus','latin_specific_epithet','dbh_class','height_class','tree_condition'], false);

var treesitefeatures = Filter(treesitetbl, treesitesql);//isolate related 'tree site' features

var treesite = First(treesitefeatures); //isolate the individual feature

if (Count(treesitefeatures) == 0) {
    return ""
}
else {
    return Proper(treesite.latin_genus) + " " + treesite.latin_specific_epithet //retun latin name of tree
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 01 Apr 2022 11:54:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/field-calculation-featureset-function-failing/m-p/1160216#M2855</guid>
      <dc:creator>ajevans429</dc:creator>
      <dc:date>2022-04-01T11:54:58Z</dc:date>
    </item>
  </channel>
</rss>

