<?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 - FeatureSetByRelationshipName in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203075#M513</link>
    <description>&lt;P&gt;The result is a featureset, so you can loop over it or call first on it, such as :&lt;/P&gt;&lt;P&gt;var related = FeatureSetByRelationshipName($feature,'MTH_Campgrounds', ["SITE_ID"], false)&lt;/P&gt;&lt;P&gt;return First(related)['SITE_ID']&lt;/P&gt;</description>
    <pubDate>Mon, 15 Aug 2022 22:58:08 GMT</pubDate>
    <dc:creator>MikeMillerGIS</dc:creator>
    <dc:date>2022-08-15T22:58:08Z</dc:date>
    <item>
      <title>Arcade - FeatureSetByRelationshipName</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203043#M512</link>
      <description>&lt;P&gt;Hello,&amp;nbsp; I am trying to populate a field (Site_ID) in a related table using the arcade function FeatureSetByRelationshipName.&amp;nbsp; The related feature that I am trying to pull from is called MTH_Campgrounds.&lt;/P&gt;&lt;P&gt;In Field Maps I want to select a point (campground in this example case) and select the related table icon and enter data into the form I created for the table.&amp;nbsp; Hopefully, this code will reduce the potential for error while inputting data into the table's form.&amp;nbsp; The feature and table are related using Global IDs.&amp;nbsp; The field in the table will be null at first.. so I am assuming there is an if then--first kind of arcade statement.&amp;nbsp; This is where I currently am...&lt;/P&gt;&lt;P&gt;var related = FeatureSetByRelationshipName($feature,'MTH_Campgrounds', ["SITE_ID"], false)&lt;/P&gt;&lt;P&gt;return related&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&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;</description>
      <pubDate>Tue, 16 Aug 2022 00:01:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203043#M512</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-16T00:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - FeatureSetByRelationshipName</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203075#M513</link>
      <description>&lt;P&gt;The result is a featureset, so you can loop over it or call first on it, such as :&lt;/P&gt;&lt;P&gt;var related = FeatureSetByRelationshipName($feature,'MTH_Campgrounds', ["SITE_ID"], false)&lt;/P&gt;&lt;P&gt;return First(related)['SITE_ID']&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 22:58:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203075#M513</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2022-08-15T22:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - FeatureSetByRelationshipName</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203078#M514</link>
      <description>&lt;P&gt;Thank you for the response!&amp;nbsp; When I use that code I get this error response&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Execution Error:&lt;/SPAN&gt;&lt;SPAN&gt;Cannot read properties of null (reading 'toString')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 23:30:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203078#M514</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-15T23:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - FeatureSetByRelationshipName</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203082#M515</link>
      <description>&lt;P&gt;Might need to add some error handling.&lt;/P&gt;&lt;P&gt;var related = FeatureSetByRelationshipName($feature,'MTH_Campgrounds', ["SITE_ID"], false)&lt;/P&gt;&lt;P&gt;var record = First(related)&lt;/P&gt;&lt;P&gt;if (IsEmpty(record)){&lt;/P&gt;&lt;P&gt;&amp;nbsp; return "No Record Found"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;return record['SITE_ID']&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 23:37:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203082#M515</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2022-08-15T23:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - FeatureSetByRelationshipName</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203517#M519</link>
      <description>&lt;P&gt;So I learned that the FeatureSetByRelationshipName references the relationship class which I titled Evaluations.&amp;nbsp; So I enter that and the test runs!&amp;nbsp; But when I open the field maps mobile application it says calculation failed.&amp;nbsp; Any ideas?&lt;/P&gt;&lt;P&gt;var related = FeatureSetByRelationshipName($feature, "Evaluations", ['SITE_ID'], false)&lt;/P&gt;&lt;P&gt;var record = First(related)&lt;/P&gt;&lt;P&gt;if (IsEmpty(record)){&lt;/P&gt;&lt;P&gt;return "No Record Found"&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;return record['SITE_ID']&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!!!!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 21:49:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203517#M519</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-16T21:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - FeatureSetByRelationshipName</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203647#M520</link>
      <description>&lt;P&gt;What type of field is SITE_ID, if it is numeric, that makes sense:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var related = FeatureSetByRelationshipName($feature, "Evaluations", ['SITE_ID'], false)&lt;/P&gt;&lt;P&gt;var record = First(related)&lt;/P&gt;&lt;P&gt;if (IsEmpty(record)){&lt;/P&gt;&lt;P&gt;return &amp;lt;ADD THE ASSIGNED TO FIELD HERE, SUCH AS $feature.THEFIELDTHISISASSIGNEDTO&amp;gt;&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;return record['SITE_ID']&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 10:13:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203647#M520</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2022-08-17T10:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - FeatureSetByRelationshipName</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203769#M521</link>
      <description>&lt;P&gt;Got the code to work, someone suggesting I don't use the FeatureSetByRelationshipName because it has some bugs, so I tried this and it works!&amp;nbsp; Thanks for all your help&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/188597"&gt;@MikeMillerGIS&lt;/a&gt;.&amp;nbsp; I was curious though what if the field site ID wasn't numeric, what if it was text would you change anything?&lt;/P&gt;&lt;P&gt;Here is the functioning code:&lt;/P&gt;&lt;P&gt;var related = FeatureSetByName($datastore,"MTH_Campgrounds", ['SITE_ID'], false)&lt;/P&gt;&lt;P&gt;var record = First(related)&lt;/P&gt;&lt;P&gt;if (IsEmpty(record)){&lt;/P&gt;&lt;P&gt;return $feature.TestID&lt;BR /&gt;}&lt;BR /&gt;return record['SITE_ID']&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 15:27:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203769#M521</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-17T15:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - FeatureSetByRelationshipName</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203967#M522</link>
      <description>&lt;P&gt;That code is incorrect. That will always return the first record in that table. You need to use filter and build a sql clause to get the record that matches $feature&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 21:04:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203967#M522</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2022-08-17T21:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - FeatureSetByRelationshipName</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203969#M523</link>
      <description>&lt;P&gt;Here is an example that might help.&amp;nbsp; &lt;A href="https://github.com/Esri/arcade-expressions/blob/master/attribute_rule_calculation/MoveFieldToParent.js" target="_blank"&gt;https://github.com/Esri/arcade-expressions/blob/master/attribute_rule_calculation/MoveFieldToParent.js&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 21:06:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1203969#M523</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2022-08-17T21:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - FeatureSetByRelationshipName</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1244004#M694</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/188597"&gt;@MikeMillerGIS&lt;/a&gt;&amp;nbsp;I added an attribute rule (Pro 2.9.5) to populate a field in the FC based on the value entered in the same field in the related table, on insert. Odd thing is when I test it and add a new related record to the FC, the field in the related record gets auto populated with the globalID, so I am not sure what that's about. And if I just manually edit that field to test the actual rule, the field does not populate in the feature class after the related record is added and saved.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// This rule will update an attribute in the parent feature

// Store the parent feature global from the key field in the relationship
var parent_id = $feature.GlobalID;
if (IsEmpty(parent_id))
    return parent_id;

// force to upper as the sql is case sensitive
parent_id = Upper(parent_id);

// Using the GDB name, get the parent classes records and Global ID field
var parent_class = FeatureSetByName($datastore, "Utilities_Model.GISADMIN.ssManhole", ["globalid", 'Lid_Condition'], false);
// Filter the parent class for only related features
var parent_records = Filter(parent_class, "globalid = @parent_id");

var updates = [];
var i = 0;
var new_value = 'Lid_Condition';
 
if (IsEmpty($feature.Lid_Condition) == False)
{
    new_value = $feature.Lid_Condition
 
}       

// Loop through each  feature, create a dict of the Global ID and the new value date
for (var row in parent_records) {
    // If the parent row is null or has a different value, updated it
    if (IsEmpty(row['Lid_Condition']) || row['Lid_Condition'] != new_value)
    {
        updates[i++] = {
            'globalid': parent_id,
            'attributes': {"Lid_Condition": new_value}    
        };
    }
}

// Return the original value in the result parameter, as to not lost the entered value
// Using the edit parameter,  return the class and list of updates
return {
'result': parent_id,
'edit': [
            {'className': 'Utilities_Model.GISADMIN.ssManhole',
             'updates': updates
            } 
        ]
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2022 16:30:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1244004#M694</guid>
      <dc:creator>JohnWatson_EBA</dc:creator>
      <dc:date>2022-12-28T16:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - FeatureSetByRelationshipName</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1244505#M695</link>
      <description>&lt;P&gt;There is an order of operations issue here.&amp;nbsp; When the related record is created, I do not believe the Parent Global ID is applied to the child.&amp;nbsp; This may occur on an update.&amp;nbsp; So you could check on Update and monitor if that field has changed and then if the ParentGUID field has changed, then fire your rule.&lt;/P&gt;&lt;P&gt;Also, this code is the features GlobalID, not the Parent, you need to get $feature.ParentID field&lt;/P&gt;&lt;PRE&gt;var parent_id = $feature.GlobalID;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 11:06:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-featuresetbyrelationshipname/m-p/1244505#M695</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2022-12-30T11:06:59Z</dc:date>
    </item>
  </channel>
</rss>

