<?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 Set an attribute if another attribute is found in a SQL table? in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/set-an-attribute-if-another-attribute-is-found-in/m-p/1064597#M134</link>
    <description>&lt;P&gt;Is it possible to create an attribute rule that would set a flag if a different attribute is found in a SQL table?&lt;/P&gt;&lt;P&gt;I have a feature class which each has a unique ID #. Could I set an attribute rule to look for that number in a SQL table, and if it exists, set a flag?&lt;/P&gt;&lt;P&gt;If so, how would I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Jun 2021 13:04:58 GMT</pubDate>
    <dc:creator>LLCCG</dc:creator>
    <dc:date>2021-06-03T13:04:58Z</dc:date>
    <item>
      <title>Set an attribute if another attribute is found in a SQL table?</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/set-an-attribute-if-another-attribute-is-found-in/m-p/1064597#M134</link>
      <description>&lt;P&gt;Is it possible to create an attribute rule that would set a flag if a different attribute is found in a SQL table?&lt;/P&gt;&lt;P&gt;I have a feature class which each has a unique ID #. Could I set an attribute rule to look for that number in a SQL table, and if it exists, set a flag?&lt;/P&gt;&lt;P&gt;If so, how would I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 13:04:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/set-an-attribute-if-another-attribute-is-found-in/m-p/1064597#M134</guid>
      <dc:creator>LLCCG</dc:creator>
      <dc:date>2021-06-03T13:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: Set an attribute if another attribute is found in a SQL table?</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/set-an-attribute-if-another-attribute-is-found-in/m-p/1064604#M135</link>
      <description>&lt;P&gt;I fear I don't really understand what you're asking.&lt;/P&gt;&lt;P&gt;Here's what I understood: You have a feature class FC with the fields FC.UniqueID and FC.Flag and a table TBL with the field TBL.UniqueID. If you add or edit a feature in FC, you want to set FC.Flag depending on whether FC.UniqueID is in TBL.UniqueID. Correct?&lt;/P&gt;&lt;P&gt;This would be a way to do it:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation rule
// Field: Flag
// Triggers: Insert, Update

// load the table
var table = FeatureSetByName($datastore, "DatabaseName.TableOwner.TableName", ["UniqueID"])

// filter table by UniqueID
var uid = $feature.UniqueID
var filtered_table = Filter(table, "UniqueID = @uid")

// return 0 if the feature's UniqueID is not found in the table
if(filtered_table == null || Count(filtered_table) == 0) {
  return 0
}
// return 1 if the feature's UniqueID is in the table
return 1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 13:20:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/set-an-attribute-if-another-attribute-is-found-in/m-p/1064604#M135</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-06-03T13:20:23Z</dc:date>
    </item>
  </channel>
</rss>

