<?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>Code not behaving same when I used localVariable with fixed number, expressionrule</title><link>https://community.appian.com/discussions/f/new-to-appian/28365/code-not-behaving-same-when-i-used-localvariable-with-fixed-number-expressionrule</link><description>Hi Experts, 
 Below Block-A code line is working fine, whereas Block-B is not working even though &amp;quot; tointeger(index(rule!AB_getReviewKey(key: 100),&amp;quot;reviewkey&amp;quot;,null()))&amp;quot; is returned 2. 
 Any comments please. 
 ----------------------- Block-A ---------</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Code not behaving same when I used localVariable with fixed number, expressionrule</title><link>https://community.appian.com/thread/111041?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 17:43:29 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:97253266-5c2a-47a6-a09b-46871f669cd9</guid><dc:creator>swapnar6405</dc:creator><description>&lt;p&gt;Thank you Mike for your help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code not behaving same when I used localVariable with fixed number, expressionrule</title><link>https://community.appian.com/thread/111032?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 14:26:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:49dfefe2-bec9-4bdb-964e-f9f97cabca1a</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;You should amend rule!AB_getReviewKey to return a single item if the expected output is always single.&amp;nbsp; If it isn&amp;#39;t, then you should use square brackets or index() when calling it in order to get a single value into your local variable.&lt;/p&gt;
&lt;p&gt;Also, when posting code snippets (even short ones like this) please use a Code Box and make sure to paste indented code - it makes it much easier to read / mentally process for us.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  local!reviewkey: tointeger(
    index(  /* use index() to get an index (1) */
      property(rule!AB_getReviewKey(key: 100), &amp;quot;reviewkey&amp;quot;, null()), /* use property() to get a property (.reviewKey) */
      1,
      null()
    )
  ),
  local!excludeKeys: if(
    local!reviewkey = 2,
    { 1, 3, 4},
    if(local!reviewkey = 5, { 1,3,4,5,6 }, {1,2,3 })
  ),
  
  local!excludeKeys
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code not behaving same when I used localVariable with fixed number, expressionrule</title><link>https://community.appian.com/thread/111031?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 14:16:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:03a320b0-2f0b-4324-b224-e4fec29e2262</guid><dc:creator>swapnar6405</dc:creator><description>&lt;p&gt;Yes Stefan.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;tointeger(index(rule!AB_getReviewKey(key: 100),&amp;quot;reviewkey&amp;quot;,null()))&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;returning list of Number (integer)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/62/pastedimage1681395399885v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code not behaving same when I used localVariable with fixed number, expressionrule</title><link>https://community.appian.com/thread/111029?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 13:48:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bd09b84c-6a16-4f57-ae25-3385e3516024</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Try the below snippet. This is a weird edge case in the evaluation of the comparison operator.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;if({1} = 2, {1,2}, {3,4})&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code not behaving same when I used localVariable with fixed number, expressionrule</title><link>https://community.appian.com/thread/111027?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 13:03:32 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:22326d93-c02f-4984-9d77-90f1b0a09da1</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Could it be that &amp;quot;&lt;span&gt;local!reviewkey&amp;quot; is a list of integers in your last example?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code not behaving same when I used localVariable with fixed number, expressionrule</title><link>https://community.appian.com/thread/111023?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 12:39:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:38f6c9fa-741f-4346-a2cc-a9434267a5cd</guid><dc:creator>swapnar6405</dc:creator><description>&lt;p&gt;In the first, second screen shots I am getting the required o/p where as in last screen shot, instead of getting an array o/p, I am just getting 1 as an o/p and which is of type List of Number (integer).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;a!localVariables(&lt;br /&gt; local!reviewkey: 2,&lt;br /&gt; local!excludeKeys: if(&lt;br /&gt; local!reviewkey = 2,&lt;br /&gt; { 1, 3, 4},&lt;br /&gt; if(local!reviewkey = 5, { 1,3,4,5,6 }, {1,2,3 })&lt;br /&gt; ),&lt;br /&gt; local!excludeKeys&lt;br /&gt;)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;o/p:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/62/pastedimage1681389353618v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;-------------------&lt;/p&gt;
&lt;p&gt;a!localVariables(&lt;br /&gt; local!reviewkey: 5,&lt;br /&gt; local!excludeKeys: if(&lt;br /&gt; local!reviewkey = 2,&lt;br /&gt; { 1, 3, 4},&lt;br /&gt; if(local!reviewkey = 5, { 1,3,4,5,6 }, {1,2,3 })&lt;br /&gt; ),&lt;br /&gt; local!excludeKeys&lt;br /&gt;)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;o/p:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/62/pastedimage1681389394062v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;----------------------&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;a!localVariables(&lt;br /&gt; local!reviewkey: tointeger(index(rule!AB_getReviewKey(key: 100),&amp;quot;reviewkey&amp;quot;,null())),&lt;br /&gt; local!excludeKeys: if(&lt;br /&gt; local!reviewkey = 2,&lt;br /&gt; { 1, 3, 4},&lt;br /&gt; if(local!reviewkey = 5, { 1,3,4,5,6 }, {1,2,3 })&lt;br /&gt; ),&lt;br /&gt; local!excludeKeys&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;O/P:&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/62/pastedimage1681389537756v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code not behaving same when I used localVariable with fixed number, expressionrule</title><link>https://community.appian.com/thread/111020?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 12:29:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e62d4a79-2461-46db-a128-dba5400cc443</guid><dc:creator>swapnar6405</dc:creator><description>&lt;p&gt;If I pass 2 or 5, I am able to see the&amp;nbsp;&lt;span&gt;local!excludeKeys with required array o/p, whereas when I use the expression rule&amp;nbsp;it is not working.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In my expression rule I am using .data at the end and when it test I was getting integer output only.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is some thing wrong with my any type conversion here.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code not behaving same when I used localVariable with fixed number, expressionrule</title><link>https://community.appian.com/thread/110996?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 05:09:54 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:052caf30-8021-4279-bd1b-2ce88b15979b</guid><dc:creator>Amaan Shekh</dc:creator><description>&lt;p&gt;Can you please provide us with more info like the error message or something like ou&lt;span&gt;tput so&amp;nbsp;&lt;/span&gt;that so that we can tell what wrong is going on.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code not behaving same when I used localVariable with fixed number, expressionrule</title><link>https://community.appian.com/thread/110993?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 02:30:43 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c703faa1-a4ca-4a21-ae10-24e6a68db390</guid><dc:creator>sanchitg0002</dc:creator><description>&lt;p&gt;Are you sure&lt;pre class="ui-code" data-mode="text"&gt;tointeger(index(rule!AB_getReviewKey(key: 100),&amp;quot;reviewkey&amp;quot;,null()))&lt;/pre&gt;&lt;span&gt;&amp;nbsp;is returning 2? If this rule is a QE or QR then I can&amp;#39;t see you are indexing &amp;quot;data&amp;quot; from it first (or you may have indexed it in the rule itself). Cannot say much, code looks fine.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>