<?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: Need Help Modifying this code for my Attribute Rule in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/need-help-modifying-this-code-for-my-attribute/m-p/1278829#M818</link>
    <description>&lt;P&gt;You can use the &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#orderby" target="_self"&gt;OrderBy&lt;/A&gt; function to sort it and then get the first record of that ordered FeatureSet.&lt;/P&gt;</description>
    <pubDate>Fri, 14 Apr 2023 15:47:03 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2023-04-14T15:47:03Z</dc:date>
    <item>
      <title>Need Help Modifying this code for my Attribute Rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/need-help-modifying-this-code-for-my-attribute/m-p/1278822#M817</link>
      <description>&lt;P&gt;Goal is to copy a list of the most resent attributes from a related table back to the Related Feature Class.&lt;/P&gt;&lt;P&gt;The feature class is called SampleSites, the related table is for collecting water samples for the that site.&lt;/P&gt;&lt;P&gt;Inspection Table is related to the Sample Sites GolbalID field and stored in a field called "&lt;SPAN&gt;SampleSites_Rel" in the Inspection&amp;nbsp;Table&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The Expression I am using now only gets the first record of the "inspection" variable in the Filter, I have tried "Max" and was not successful, I have tried to Sort the Table and failed " I had a &lt;SPAN&gt;wrong number of arguments" trying to add the sort to the expression.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var vFeature_SampleSiteGlobalID = $feature.GlobalID;
var InspectionTable = FeatureSetByName($datastore, "SDEP.SDEADMIN.WaterSampleInspections");
var Inspection = Filter(InspectionTable, "SampleSites_Rel = @vFeature_SampleSiteGlobalID");
var sv = first(Inspection);

if (sv != null) {
  return {
    "result" : {
      "attributes" : {
        "SampleDate" : sv.SampleDate,
        "Cl" : sv.Cl,
        "pH" : sv.pH,
        "NH3" :sv.NH3,
        "Color" :sv.Color,
        "Temperature" : sv.Temperature,
        "HPC" : sv.HPC
      }
    }
  };
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any help would be much appreciated&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 15:31:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/need-help-modifying-this-code-for-my-attribute/m-p/1278822#M817</guid>
      <dc:creator>BrianHumphries1</dc:creator>
      <dc:date>2023-04-14T15:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help Modifying this code for my Attribute Rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/need-help-modifying-this-code-for-my-attribute/m-p/1278829#M818</link>
      <description>&lt;P&gt;You can use the &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#orderby" target="_self"&gt;OrderBy&lt;/A&gt; function to sort it and then get the first record of that ordered FeatureSet.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 15:47:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/need-help-modifying-this-code-for-my-attribute/m-p/1278829#M818</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-04-14T15:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help Modifying this code for my Attribute Rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/need-help-modifying-this-code-for-my-attribute/m-p/1278844#M819</link>
      <description>&lt;P&gt;Thank you that did the trick&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;added the variable&amp;nbsp; to perform the Order&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var InspectionOrderBy = OrderBy(Inspection, 'SampleDate DESC')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Working code with the OderBy&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var vFeature_SampleSiteGlobalID = $feature.GlobalID;
var InspectionTable = FeatureSetByName($datastore, "SDEP.SDEADMIN.WaterSampleInspections");
var Inspection = Filter(InspectionTable, "SampleSites_Rel = @vFeature_SampleSiteGlobalID");
var InspectionOrderBy = OrderBy(Inspection, 'SampleDate DESC')
var sv = first(InspectionOrderBy);

if (sv != null) {
  return {
    "result" : {
      "attributes" : {
        "SampleDate" : sv.SampleDate,
        "Cl" : sv.Cl,
        "pH" : sv.pH,
        "NH3" :sv.NH3,
        "Color" :sv.Color,
        "Temperature" : sv.Temperature,
        "HPC" : sv.HPC
      }
    }
  };
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 16:01:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/need-help-modifying-this-code-for-my-attribute/m-p/1278844#M819</guid>
      <dc:creator>BrianHumphries1</dc:creator>
      <dc:date>2023-04-14T16:01:58Z</dc:date>
    </item>
  </channel>
</rss>

