<?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: Attribute rule for Inserting record to table in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-for-inserting-record-to-table/m-p/1264438#M745</link>
    <description>&lt;P&gt;Hmm, according to the version matrix, ArcGIS Server 10.8.1 should include Arcade 1.10 at least. Filter() was released in 1.5. What error do you get?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, you could try FeaturesetByRelationshipName(), but that was released in Arcade 1.8, so it will probably be the same.&lt;/P&gt;&lt;P&gt;You could also do it with a for loop. It will be slower than Filter(), especially if table B has many entries, but it should get the job done:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var table_b = FeaturesetByName($datastore, "TableB")
var gid = $feature.GLobalID
var v = null
for(var b in table_b) {
    if(b.gid_fk == gid) {
        v = b.v
        break
    }
}

return {
"edit": [{
    "className": "table C",
    "adds": [{ 
       'attributes': 
       {
         "gid_fk":$feature.globalid,
         "v": v
        }
    }]
}]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Mar 2023 12:39:49 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2023-03-06T12:39:49Z</dc:date>
    <item>
      <title>Attribute rule for Inserting record to table</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-for-inserting-record-to-table/m-p/1264350#M742</link>
      <description>&lt;P&gt;I am wondering if I could create an update attribute rule to a table A&amp;nbsp; that copies a value (V) from a field in a table B (by using the&amp;nbsp;$feature.globalid to find the record in table B) and inserting a new record into a table C to paste the V. So far, I managed to transfer the V from the $feature in table A to a new record in table C.&lt;/P&gt;&lt;P&gt;code:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;return {
"edit": [{
    "className": "table C",
    "adds": [{ 
       'attributes': 
       {
         "gid_fk":$feature.globalid
        }
    }]
}]
}&lt;/LI-CODE&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2023 20:17:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-for-inserting-record-to-table/m-p/1264350#M742</guid>
      <dc:creator>GIServicesUser</dc:creator>
      <dc:date>2023-03-05T20:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule for Inserting record to table</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-for-inserting-record-to-table/m-p/1264403#M743</link>
      <description>&lt;P&gt;You could use the Filter() function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var table_b = FeaturesetByName($datastore, "TableB")
var gid = $feature.GLobalID
var related_b_row = First(Filter("gid_fk = @gid")) // use the actual field name!
var v = IIf(related_b_row == null, null, related_b_row.V)

return {
"edit": [{
    "className": "table C",
    "adds": [{ 
       'attributes': 
       {
         "gid_fk":$feature.globalid,
         "v": v
        }
    }]
}]
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 06 Mar 2023 06:49:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-for-inserting-record-to-table/m-p/1264403#M743</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-03-06T06:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule for Inserting record to table</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-for-inserting-record-to-table/m-p/1264431#M744</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;SPAN&gt;Johannes, I tried this and works perfectly, however, another issue came up...as always, the function Filter if I am not mistaken is incompatible with my ArcGIS Server Installation 10.8.1 according to &lt;A href="https://developers.arcgis.com/arcade/guide/version-matrix/" target="_self"&gt;this&lt;/A&gt;&amp;nbsp;and I get an error while trying to publish the feature (table A) with the attribute rule...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 11:57:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-for-inserting-record-to-table/m-p/1264431#M744</guid>
      <dc:creator>GIServicesUser</dc:creator>
      <dc:date>2023-03-06T11:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule for Inserting record to table</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-for-inserting-record-to-table/m-p/1264438#M745</link>
      <description>&lt;P&gt;Hmm, according to the version matrix, ArcGIS Server 10.8.1 should include Arcade 1.10 at least. Filter() was released in 1.5. What error do you get?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, you could try FeaturesetByRelationshipName(), but that was released in Arcade 1.8, so it will probably be the same.&lt;/P&gt;&lt;P&gt;You could also do it with a for loop. It will be slower than Filter(), especially if table B has many entries, but it should get the job done:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var table_b = FeaturesetByName($datastore, "TableB")
var gid = $feature.GLobalID
var v = null
for(var b in table_b) {
    if(b.gid_fk == gid) {
        v = b.v
        break
    }
}

return {
"edit": [{
    "className": "table C",
    "adds": [{ 
       'attributes': 
       {
         "gid_fk":$feature.globalid,
         "v": v
        }
    }]
}]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 12:39:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-for-inserting-record-to-table/m-p/1264438#M745</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-03-06T12:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule for Inserting record to table</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-for-inserting-record-to-table/m-p/1264595#M746</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Johannes,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I used the loop method to write the script and even though the rule works fine on desktop, when trying to publish the table with the attribute&amp;nbsp;rule I get the same error as before&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ERROR 001487: Failed to update the published service with the server-side data location&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If I remove the attribute rule from the table A, the publishing of the table completes successfully.&lt;/P&gt;&lt;P&gt;I am not sure If the fact that the table B is a table view in the database and it is not included in the publishing service because the service has feature capability, has something to do with this error...&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 18:42:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-for-inserting-record-to-table/m-p/1264595#M746</guid>
      <dc:creator>GIServicesUser</dc:creator>
      <dc:date>2023-03-06T18:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule for Inserting record to table</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-for-inserting-record-to-table/m-p/1264684#M747</link>
      <description>&lt;P&gt;I think table b has to be included for the $datastore to work. You don't need to consume the published table b in your map/application, but it should be in the service.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 19:20:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-for-inserting-record-to-table/m-p/1264684#M747</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-03-06T19:20:19Z</dc:date>
    </item>
  </channel>
</rss>

