<?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: Issue with Arcade Calculation in FieldMaps - returns the same value everytime in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/issue-with-arcade-calculation-in-fieldmaps-returns/m-p/1581967#M7417</link>
    <description>&lt;P&gt;I also tried using&amp;nbsp;FeatureSetByPortalItem instead and that is when I get "&lt;STRONG&gt;d is null&lt;/STRONG&gt;"&lt;/P&gt;</description>
    <pubDate>Tue, 04 Feb 2025 20:10:10 GMT</pubDate>
    <dc:creator>PTW</dc:creator>
    <dc:date>2025-02-04T20:10:10Z</dc:date>
    <item>
      <title>Issue with Arcade Calculation in FieldMaps - returns the same value everytime</title>
      <link>https://community.esri.com/t5/developers-questions/issue-with-arcade-calculation-in-fieldmaps-returns/m-p/1581091#M7411</link>
      <description>&lt;P&gt;Hello! I am working on a Field Maps project where users in the field are inspecting parking lots. I am using 11.1 Enterprise Portal.&lt;/P&gt;&lt;P&gt;I created a layer of the parking lots that need to be inspected and I created a related table for the inspections. I then created a web map with the layer and now I am setting up the Field Maps form.&lt;/P&gt;&lt;P&gt;Everything is working as intended however I want to calculate a couple answers from the Parking Lots layer into the Inspection Form to ensure data accuracy like the Lot Name and the Lot ID.&lt;/P&gt;&lt;P&gt;I had this working on my AGOL prototype with the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var LotData = FeatureSetByRelationshipName($feature, "ParkingLots", ['*'], false);
var Pull = First(LotData)
if(Pull == null) {
Console("Data is null -&amp;gt; Data is empty")
} else {
Console(Pull.Lot_Name)
}
return(Pull.Lot_Name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I rewrote it to switch to Enterprise. It "works" however it always returns the attributes of Lot #1. FeatureSetByRelationShipName was not working so I switched to FeatureSetByName. New code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var LotData= FeatureSetByName($datastore,"ParkingLots", ['*'], false)
var record = First(LotData)
if (IsEmpty(record)){
return "No Record Found"
}
return record['lot_name']&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;I have a feeling I need to use Filter before First however I have not been able to get anything to work.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2025 00:27:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/issue-with-arcade-calculation-in-fieldmaps-returns/m-p/1581091#M7411</guid>
      <dc:creator>PTW</dc:creator>
      <dc:date>2025-02-01T00:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Arcade Calculation in FieldMaps - returns the same value everytime</title>
      <link>https://community.esri.com/t5/developers-questions/issue-with-arcade-calculation-in-fieldmaps-returns/m-p/1581297#M7413</link>
      <description>&lt;P&gt;Yes, you'll need the Filter function to get the proper record. Use the proper field names for the common fields linking the table to the FeatureSet in lines 1 and 3.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var asset = $feature.thecommonfield
var LotData= FeatureSetByName($datastore,"ParkingLots", ['*'], false)
var record = First(Filter(LotData, "thecommonfield = @asset)
if (IsEmpty(record)) return "No Record Found"
return record['lot_name']&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 14:28:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/issue-with-arcade-calculation-in-fieldmaps-returns/m-p/1581297#M7413</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-02-03T14:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Arcade Calculation in FieldMaps - returns the same value everytime</title>
      <link>https://community.esri.com/t5/developers-questions/issue-with-arcade-calculation-in-fieldmaps-returns/m-p/1581964#M7416</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;! Thank you for the response.&lt;/P&gt;&lt;P&gt;I found your response for another similar issue: &lt;A href="https://community.esri.com/t5/arcgis-online-questions/arcade-script-for-layer-to-layer-calculation/m-p/1506228" target="_blank"&gt;https://community.esri.com/t5/arcgis-online-questions/arcade-script-for-layer-to-layer-calculation/m-p/1506228&lt;/A&gt;&amp;nbsp; however the code is still not working.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var asset_id = $feature.guid
var LotData = FeatureSetByRelationshipName($feature, 'ParkingLots', ['*'], false)
var results = First(Filter(LotData, "GlobalID = @asset_id"))
if(IsEmpty(results)){
    return "No Record Found"
} else {
    return results['lot_name']
}&lt;/LI-CODE&gt;&lt;P&gt;First, the results are &lt;STRONG&gt;"a is null"&lt;/STRONG&gt; or sometimes I get &lt;STRONG&gt;"d is null"&lt;/STRONG&gt; and the console breaks at line 3. If I replace $feature with $datastore and remove the Filter it will just pull the data from the first parking lot.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var asset_id = $feature.guid
var LotData = FeatureSetByName($datastore,"ParkingLots", ['*'], false)
var results = First(LotData)
if(IsEmpty(results)){
    return "No Record Found"
} else {
    return results['lot_name']
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Second, if I add the Filter function back in it goes back to &lt;STRONG&gt;"a is null"&lt;/STRONG&gt;. I am wondering if the Filter's Boolean is wrong? Or is this simply a connection issue related to $feature?&lt;/P&gt;&lt;P&gt;Any thoughts? Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 20:07:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/issue-with-arcade-calculation-in-fieldmaps-returns/m-p/1581964#M7416</guid>
      <dc:creator>PTW</dc:creator>
      <dc:date>2025-02-04T20:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Arcade Calculation in FieldMaps - returns the same value everytime</title>
      <link>https://community.esri.com/t5/developers-questions/issue-with-arcade-calculation-in-fieldmaps-returns/m-p/1581967#M7417</link>
      <description>&lt;P&gt;I also tried using&amp;nbsp;FeatureSetByPortalItem instead and that is when I get "&lt;STRONG&gt;d is null&lt;/STRONG&gt;"&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 20:10:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/issue-with-arcade-calculation-in-fieldmaps-returns/m-p/1581967#M7417</guid>
      <dc:creator>PTW</dc:creator>
      <dc:date>2025-02-04T20:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Arcade Calculation in FieldMaps - returns the same value everytime</title>
      <link>https://community.esri.com/t5/developers-questions/issue-with-arcade-calculation-in-fieldmaps-returns/m-p/1582039#M7418</link>
      <description>&lt;P&gt;Update: I found another related post: &lt;A href="https://community.esri.com/t5/developers-questions/arcade-error-when-accessing-empty-feature-set/td-p/196396" target="_blank"&gt;https://community.esri.com/t5/developers-questions/arcade-error-when-accessing-empty-feature-set/td-p/196396&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;if(IsEmpty($feature.guid)) {
  return "null"
}
else {
 return First(FeatureSetByRelationshipName($feature, "ParkandRideLots", ['lot_name'], false))
}&lt;/LI-CODE&gt;&lt;P&gt;It is now returning the correct feature however it returns the entire feature starting with geometry. There seems to be an issue with the FeatureSetByRelationshipName function as it ignores the optional fieldname and includeGeometry.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 22:26:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/issue-with-arcade-calculation-in-fieldmaps-returns/m-p/1582039#M7418</guid>
      <dc:creator>PTW</dc:creator>
      <dc:date>2025-02-04T22:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Arcade Calculation in FieldMaps - returns the same value everytime</title>
      <link>https://community.esri.com/t5/developers-questions/issue-with-arcade-calculation-in-fieldmaps-returns/m-p/1582065#M7419</link>
      <description>&lt;P&gt;Alright I think I figured it out.&amp;nbsp; I'll try to include as information much as possible so if anyone else finds this thread.&lt;/P&gt;&lt;P&gt;Definitely multiple issues were encountered but this is the resulting code that works:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;if(IsEmpty($feature.guid)) {
  return "null"
}
else {
 var results = First(FeatureSetByRelationshipName($feature, "ParkingLots", ['*'], false))
 return results.lot_name
}&lt;/LI-CODE&gt;&lt;P&gt;Lines 1 and 2 solve the Filter issue - see why in the answer of this &lt;A href="https://community.esri.com/t5/developers-questions/arcade-error-when-accessing-empty-feature-set/td-p/196396" target="_self"&gt;Post&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I split the previous attempt's last line into Lines 5 &amp;amp; 6 because it was returning all of the fields as well as the geometry. Now Line 5 pulls the data but Line 6 returns only the desired field.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 00:09:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/issue-with-arcade-calculation-in-fieldmaps-returns/m-p/1582065#M7419</guid>
      <dc:creator>PTW</dc:creator>
      <dc:date>2025-02-05T00:09:58Z</dc:date>
    </item>
  </channel>
</rss>

