<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Check if data exists in database using expression rule</title><link>https://community.appian.com/discussions/f/rules/13102/check-if-data-exists-in-database-using-expression-rule</link><description>I am trying to create an Expression rule that returns true if a specific piece of data is present in a specific column of a db but I feel like I am not doing it in an efficient way. 
 My situation is analogous to this situation: 
 Database table with</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Check if data exists in database using expression rule</title><link>https://community.appian.com/thread/85672?ContentTypeID=1</link><pubDate>Fri, 10 Sep 2021 19:49:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8183ddad-5272-432e-bbc5-d67e4665e6bc</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Please paste the exact expression code you&amp;#39;re attempting to run, and post it in a code box (Insert --&amp;gt; Insert Code), with indentation left in-tact (preferably, run auto-formatting first).&lt;/p&gt;
&lt;p&gt;The code you&amp;#39;ve posted here is invalid, as you are trying to get the .totalCount property from the result and at the same time (?) get the .siteId property.&amp;nbsp; It seems as if you combined 2 of the previous examples in this thread without actually understanding how Query Entities work - honestly, it would probably be best if you study the documentation on Query Entity and became familiar with how it works and why, and what its output is and how to use them.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Check if data exists in database using expression rule</title><link>https://community.appian.com/thread/85671?ContentTypeID=1</link><pubDate>Fri, 10 Sep 2021 19:17:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f8881550-84eb-47ab-bde6-f79473ee2cf7</guid><dc:creator>vimalkumars</dc:creator><description>&lt;p&gt;Your query entity execution is failing. Check your Appian Tomcat Logs, it can provide&amp;nbsp;more information on&amp;nbsp;why query entity call is failing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Check if data exists in database using expression rule</title><link>https://community.appian.com/thread/85647?ContentTypeID=1</link><pubDate>Fri, 10 Sep 2021 09:13:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:88f2b688-f9c0-4d97-8909-b48f8e8c8907</guid><dc:creator>saurabh sharma</dc:creator><description>&lt;p&gt;if(&lt;br /&gt; property(&lt;br /&gt; a!queryEntity(&lt;br /&gt; entity: &amp;lt;cons....&amp;gt;,&lt;br /&gt; query: a!query(&lt;br /&gt; selection: a!querySelection(&lt;br /&gt; columns: {&lt;br /&gt; a!queryColumn(&lt;br /&gt; field:&amp;quot;siteid&amp;quot;&lt;br /&gt; )&lt;br /&gt; }&lt;br /&gt; ),&lt;br /&gt; filter: a!queryFilter(&lt;br /&gt; field: &amp;quot;siteid&amp;quot;,&lt;br /&gt; operator: &amp;quot;=&amp;quot;,&lt;br /&gt; value: ri!siteid&lt;br /&gt; ),&lt;br /&gt; paginginfo: a!pagingInfo(&lt;br /&gt; startIndex: 1,&lt;br /&gt; batchSize: 1&lt;br /&gt; )&lt;br /&gt; )&lt;br /&gt; ).totalCount&amp;gt;0,&lt;br /&gt; &amp;quot;siteid&amp;quot;,false)=ri!siteid,&lt;br /&gt; &amp;quot;Request Already Generated&amp;quot;,&lt;br /&gt; &amp;quot;Request Not Generated&amp;quot;&lt;br /&gt;)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am getting this Error:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Expression evaluation error at function a!queryEntity [line 3]: An error occurred while retrieving the data. Details: Unexpected error executing query (type: [TWMDecomRequestSitesDT12021], query: [queryentity expression], order by: [[Sort[siteid asc]]], filters:[(siteid = TypedValue[it=3,v=AB000444])])&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Check if data exists in database using expression rule</title><link>https://community.appian.com/thread/59054?ContentTypeID=1</link><pubDate>Sun, 12 Aug 2018 18:52:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:293987e9-6978-4dac-95d2-e3845c2af55d</guid><dc:creator>Vadivelan</dc:creator><description>Hi,&lt;br /&gt;
Query entity will always returns a DataSubset of Dictionaries.&lt;br /&gt;
&lt;br /&gt;
[startIndex=1,&lt;br /&gt;
 	 batchSize=-1,&lt;br /&gt;
 	 sort=,&lt;br /&gt;
 	 totalCount=2,&lt;br /&gt;
 	 data=1; 2,&lt;br /&gt;
 	 identifiers=1; 2]&lt;br /&gt;
&lt;br /&gt;
So, rather than doing dot notation with a!queryEntity(..).data use the total count parameter to check like a!queryEntity(..).totalCount&lt;br /&gt;
&lt;br /&gt;
Thanks,&lt;br /&gt;
Vadivelan&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Check if data exists in database using expression rule</title><link>https://community.appian.com/thread/59044?ContentTypeID=1</link><pubDate>Fri, 10 Aug 2018 22:30:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:81839f46-6866-4700-9a5f-68e54f2a77d8</guid><dc:creator>Tim</dc:creator><description>You could just use: a!queryEntity(...).totalCount &amp;gt; 0&lt;br /&gt;
This will return true or false for you.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>