<?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>Expression rule to compare two values</title><link>https://community.appian.com/discussions/f/general/23644/expression-rule-to-compare-two-values</link><description>I want to write an expression rule to compare two values: 
 first value is from rule input and second value from a db table field.If the values are same ,then another field(column) of my db table must be set to inactive or 0.</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Expression rule to compare two values</title><link>https://community.appian.com/thread/90801?ContentTypeID=1</link><pubDate>Tue, 08 Feb 2022 05:31:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:21b9ef0c-61a3-44bd-80e4-bc25eb986298</guid><dc:creator>jasmithak</dc:creator><description>&lt;p&gt;load(&lt;br /&gt; local!dbdata:{&lt;br /&gt; {id:1,isactive:1,fieldId:1,formId:2},&lt;br /&gt; {id:1,isactive:1,fieldId:1,formId:3},&lt;br /&gt; },&lt;/p&gt;
&lt;p&gt;a!forEach(&lt;br /&gt; items: local!dbdata,&lt;br /&gt; expression: if(&lt;br /&gt; and(&lt;br /&gt; tointeger(fv!item.fieldId) = ri!fieldId,&lt;br /&gt; tointeger(fv!item.formId) = ri!formId&lt;br /&gt; ),&lt;br /&gt; {id:fv!item.id,isactive:0,fieldId:fv!item.fieldId,formId:fv!item.formId},&lt;br /&gt; fv!item&lt;br /&gt; )&lt;br /&gt; )&lt;br /&gt;)&lt;/p&gt;
&lt;p&gt;I specified dbdata as dictionary in above code. cast it to CDT using type! and write the output to database entity.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expression rule to compare two values</title><link>https://community.appian.com/thread/90763?ContentTypeID=1</link><pubDate>Mon, 07 Feb 2022 14:43:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cdb0d3de-b391-467f-af06-678ec2cf0960</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;You probably need to look into doing this in a process model; a single expression rule can&amp;#39;t really do all the different things you&amp;#39;re describing here inherently.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expression rule to compare two values</title><link>https://community.appian.com/thread/90725?ContentTypeID=1</link><pubDate>Sun, 06 Feb 2022 12:32:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:adefc5de-a1ac-4010-8646-95a3470fbf1d</guid><dc:creator>s0001</dc:creator><description>&lt;p&gt;Hi Mike&lt;/p&gt;
&lt;p&gt;Thanks for your response,by the line &amp;quot;&lt;span&gt;another field of my table must be set to inactive&amp;quot;,what I mean is I have a column name &amp;quot;is active&amp;quot; in my db Table. I also have columns &amp;quot;fieldid&amp;quot; and &amp;quot;formid&amp;quot; in my DB table.So what I exactly want to do is get rule inputs for formid and fieldid.If the rule input values of these 2 fields matches(same value) with the value i have in the db table for &amp;quot;fieldid&amp;quot; and &amp;quot;formid&amp;quot; column, then my &amp;quot;isactive&amp;quot; column must be set to 0 or disabled.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expression rule to compare two values</title><link>https://community.appian.com/thread/90704?ContentTypeID=1</link><pubDate>Fri, 04 Feb 2022 18:27:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:093a65a3-5a50-4f34-b46b-4c44a3838b57</guid><dc:creator>Akhil Sharma</dc:creator><description>&lt;p&gt;To do the comparison, the&amp;nbsp;value should be retrieved from the database. Use query entity to get the value from backend, compare it and set the value (write into database).&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expression rule to compare two values</title><link>https://community.appian.com/thread/90701?ContentTypeID=1</link><pubDate>Fri, 04 Feb 2022 16:05:24 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ebb4d310-faa6-4c4b-a67c-357844ba8d33</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;FYI, you&amp;#39;re able to edit your post if you want to change something, it&amp;#39;s not really needed to post essentially the same thing again.&lt;br /&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/pastedimage1643990558296v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;For your question, you should be able to query from your database table (using &lt;em&gt;a!queryEntity()&lt;/em&gt; or, preferably, referencing an existing expression rule you&amp;#39;ve already set up to handle queries to that table), and compare the result to the input value.&amp;nbsp; I&amp;#39;m not exactly clear what you mean when you say &amp;quot;another field of my table must be set to inactive&amp;quot;, as an expression rule itself cannot change data in a DB table - what you describe will probably be most easily accomplished by using a process model which sets the desired value determined by some initial logic then writes that row back to your table.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>