<?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 with same rule inputs should produce different results</title><link>https://community.appian.com/discussions/f/rules/20806/expression-rule-with-same-rule-inputs-should-produce-different-results</link><description>I have the following situation: 
 - search text field for entering the client&amp;#39;s ID 
 - ADD button that does the search and adds the client to the grid 
 - pretty complex UI which has this part regarding ADD button: 
 
 
 Action order is as follows. 
</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Expression rule with same rule inputs should produce different results</title><link>https://community.appian.com/thread/81077?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 15:10:42 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d9ef75cc-b88c-4f1d-aca4-c33857bc134c</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I&amp;#39;ve been there - i&amp;#39;ve dealt with a lot of &amp;quot;legacy&amp;quot; issues like this too.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expression rule with same rule inputs should produce different results</title><link>https://community.appian.com/thread/81076?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 15:08:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bb2fec9a-8c76-4c68-bccf-162478027956</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;I&amp;#39;ll add a +1 for taking the time to simplify the logic whenever possible.&amp;nbsp; Every &amp;quot;Monster&amp;quot; project I&amp;#39;ve inherited, it has been quicker to rebuild and support lighter code later than to&amp;nbsp;support&amp;nbsp;a massive form&amp;#39;s spaghetti code in production..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expression rule with same rule inputs should produce different results</title><link>https://community.appian.com/thread/81074?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 15:04:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3f2415cf-1b93-439c-b4a9-b4e1bbc8c3f6</guid><dc:creator>ivanm0004</dc:creator><description>&lt;p&gt;Unfortunately, in this case I had no option to think about best practices since i wasn&amp;#39;t the designer. I am just a &amp;quot;lucky winner&amp;quot; who received this legacy :)&amp;nbsp; Maybe sometimes in the future someone will have enough time to rewrite it and &amp;quot;calm down the monster&amp;quot;. I believe Stefan&amp;#39;s and yours responses will be another PRO argument why to do this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expression rule with same rule inputs should produce different results</title><link>https://community.appian.com/thread/81068?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 14:55:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b02ad45e-6c53-4fbd-b2e0-55eac6726c75</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="46508" url="~/discussions/f/rules/20806/expression-rule-with-same-rule-inputs-should-produce-different-results/81058#81058"]Could it be something with the fact that mentioned user interface is a &amp;quot;monster&amp;quot; [/quote]
&lt;p&gt;You&amp;#39;re correct in that this is often a recipe for trouble and confusion.&amp;nbsp; I bend over backwards to make sure my forms don&amp;#39;t pass a certain complexity threshold, because debugging and future maintenance quickly becomes a nightmare.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expression rule with same rule inputs should produce different results</title><link>https://community.appian.com/thread/81059?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 13:43:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5a4b38d6-55cf-4aaa-9f78-f7244941c568</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;That is a quite complex scenario. My approach would be to drill down and add debugging information along the way. There is a plugin &amp;quot;Log a Message&amp;quot; which allows you to write to the tomcat-std-out log.&lt;/p&gt;
&lt;p&gt;This way you should be able to find out what is going on behind the scenes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expression rule with same rule inputs should produce different results</title><link>https://community.appian.com/thread/81058?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 13:22:53 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6cc93ad6-d574-4988-a45b-5a4e7390b8d9</guid><dc:creator>ivanm0004</dc:creator><description>&lt;p&gt;Thank you for the clarifications. I intended to &amp;quot;modernize&amp;quot; this expression rule and replace with(). I&amp;#39;ve made some tests and it seems that rule itself (when it is invoked from EDIT rule screen) works fine and doesn&amp;#39;t have problems with caching.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve tried to:&lt;/p&gt;
&lt;p&gt;- define rule inputs to mimic the case from the interface,&lt;/p&gt;
&lt;p&gt;- then run the search for non existing client,&lt;/p&gt;
&lt;p&gt;- then add the client into remote database&lt;/p&gt;
&lt;p&gt;- finally run search again without leaving or refreshing the EDIT screen.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Everything worked fine.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It seems that it has some issues only when this rule is invoked from the user interface.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If it helps you understand better this is the more detailed logic:&lt;/p&gt;
&lt;p&gt;- in user interface local variable local!client is refreshed on each click of ADD button (as shown in the code snippet)&lt;/p&gt;
&lt;p&gt;- client&amp;#39;s data are fetched via expression rule rule!APP_getclient&lt;/p&gt;
&lt;p&gt;- rule!APP_getclient has multiple local variables within with() that help produce the final output&lt;/p&gt;
&lt;p&gt;- one of those local variables invokes another expression rule which decides which of 2 available integrations is called to retrieve client&lt;/p&gt;
&lt;p&gt;- these integration retrieve the data from remote database&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As far as i can see, I have forced the refresh on both key points.&lt;/p&gt;
&lt;p&gt;1) a!localVariables on user interface&lt;/p&gt;
&lt;p&gt;2) with() inside the expression rule&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Could it be something with the fact that mentioned user interface is a &amp;quot;monster&amp;quot; with multiple nested a!localVariables() and FOR loops?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;There are 2 more a!localVariables above the one from the snippet (lets say &amp;quot;parent a!localVariables()&amp;quot;).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expression rule with same rule inputs should produce different results</title><link>https://community.appian.com/thread/81048?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 09:22:56 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:080a3902-8d07-4bc4-a9e1-04ed98743e3f</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;with()/load() is the old way, a!localVariables is the new way. Variables inside with() are reevaluated on each interaction. There is no real benefit in refactoring this. But you have to make sure that the whole chain of calls and local variables uses with() or a!localVariables with refreshAlways.&lt;/p&gt;
&lt;p&gt;Do you have any chance to find out whether this is a DB caching issue?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expression rule with same rule inputs should produce different results</title><link>https://community.appian.com/thread/81045?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 07:50:39 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7aa2a8c6-bb38-408b-998b-8a9e0998f58d</guid><dc:creator>ivanm0004</dc:creator><description>&lt;p&gt;It is built with with() and contains local variables. One of the local variables calls another expression rule which then fetches client from the remote database (query entity). Should I try with a!localvariables and refreshAlways instead of with? Are there any benefits?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expression rule with same rule inputs should produce different results</title><link>https://community.appian.com/thread/81042?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 05:55:47 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a2fd2205-390e-4a60-8d18-27456398463f</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Appian caches DB calls. If the inputs do not change, then it might&amp;nbsp;return the cached values. And, by any chance, how is the expression APP_getClient() built? In case there is local variables, it can happen that these are not refreshed. This can happen with load() and a!localVariables not set to refreshAlways.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>