<?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>extended if() functionality</title><link>https://community.appian.com/discussions/f/new-to-appian/30475/extended-if-functionality</link><description>Hi, 
 
 I&amp;#39;m relatively new to Appian and came across a use of the if() function that didn&amp;#39;t seem to fit with the online documentation and syntax. According to some more experienced developers it wasn&amp;#39;t unusual, but I was disappointed not being able to</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: extended if() functionality</title><link>https://community.appian.com/thread/121163?ContentTypeID=1</link><pubDate>Tue, 31 Oct 2023 15:28:08 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:954264d4-a4fa-4d87-8c8b-df94ebded2f2</guid><dc:creator>caroline.brautigan</dc:creator><description>&lt;p&gt;If you do need to check a value against multiple conditions, a good alternative to nested if() statements (or using this undocumented behavior in a single if()) is the a!match() function.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.appian.com/suite/help/23.3/fnc_logical_match.html"&gt;https://docs.appian.com/suite/help/23.3/fnc_logical_match.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s an example that shows using it to check multiple conditions:&amp;nbsp;&lt;a href="https://docs.appian.com/suite/help/23.3/fnc_logical_match.html#using-the-equals,-whentrue,-and-then-parameters"&gt;https://docs.appian.com/suite/help/23.3/fnc_logical_match.html#using-the-equals,-whentrue,-and-then-parameters&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: extended if() functionality</title><link>https://community.appian.com/thread/121125?ContentTypeID=1</link><pubDate>Tue, 31 Oct 2023 11:28:49 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:474eb8cc-641c-4192-aa50-215d8d5bde8f</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;Hah! The first (Zen) rule of Appian is &amp;quot;Developing Appian requires great peace of mind&amp;quot;...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: extended if() functionality</title><link>https://community.appian.com/thread/121124?ContentTypeID=1</link><pubDate>Tue, 31 Oct 2023 11:26:22 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f6ad7fbd-332a-45db-a5dc-628f3d231a9b</guid><dc:creator>davidkessler</dc:creator><description>&lt;p&gt;Thanks,Stewart - your detail and Stefan&amp;#39;s summary hit my brain lock from both sides! Thank you so much. (Also, sleep helps.)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: extended if() functionality</title><link>https://community.appian.com/thread/121122?ContentTypeID=1</link><pubDate>Tue, 31 Oct 2023 11:10:19 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:82a36fe4-be82-4e37-9536-8c86870aa5c2</guid><dc:creator>davidkessler</dc:creator><description>&lt;p&gt;Thanks for looking. Yes, in the morning this does make perfect sense!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: extended if() functionality</title><link>https://community.appian.com/thread/121111?ContentTypeID=1</link><pubDate>Tue, 31 Oct 2023 09:55:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5e62542c-c2b4-45a5-9765-be1706f90ba9</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;To explain the syntax of the example expression you&amp;#39;ve provided...it does conform to the documented pattern - it has a condition, and returns a valueIfTrue and a valueIfFalse.&lt;/p&gt;
&lt;p&gt;Your example is a bit more complex in the that the returned values are themselves not fixed values but are evaluated at runtime. If you took each of the posisble values to be returned and evaluated them in isolation they&amp;#39;d return wither true or false. That is:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;local!level= cons!APPL_LVL_THIS is either true or false&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;and&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;local!level = cons!APPL_LVL_THAT is either true or false&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;...but only one of them will be evaluated/returned depending on whether&amp;nbsp;local!status = cons!APPL_STS_OFF returns true or false.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So there&amp;#39;s nothing&amp;nbsp;wrong with&amp;nbsp;the syntax of the your if() statement, other than it&amp;#39;s hard to read and (probably) hard to debug. The code could have local! variables set to the individual results of those evaluations and used in your if() statement, like this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;local!isLevelThis: local!level= cons!APPL_LVL_THIS,

local!isLevelThat: local!level= cons!APPL_LVL_THAT,

showWhen: if(
              local!status = cons!APPL_STS_OFF,
              local!isLevelThis,
              local!isLevelThat
            )&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I would find that easier to read/maintain that the example you provided but it is more verbose and does have the (probably immaterial) overhead of evaluating both values when only one is going to be returned.&lt;/p&gt;
&lt;p&gt;By extension you could even code it like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;local!isLevelThis: local!level= cons!APPL_LVL_THIS,

local!isLevelThat: local!level= cons!APPL_LVL_THAT,

local!isStatusOff: local!status = cons!APPL_STS_OFF,

showWhen: if(
              local!isStatusOff,
              local!isLevelThis,
              local!isLevelThat
            )&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;which is even easier to read and debug imo. I&amp;#39;m sure others will wade in with their opinions...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: extended if() functionality</title><link>https://community.appian.com/thread/121095?ContentTypeID=1</link><pubDate>Tue, 31 Oct 2023 07:12:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:02e6933a-1490-4812-ae2e-724ec9adffbf</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;There is an edge case in the internal implementation which, theoretically, allows you to put multiple conditions into an if(). But this again can lead to more edge cases depending on which other values you use.&lt;/p&gt;
&lt;p&gt;So, from my perspective, this is pretty simple. ONE if() takes exactly ONE condition!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>