<?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>Index default value</title><link>https://community.appian.com/discussions/f/general/21483/index-default-value</link><description>Hi, 
 
 I have this code where if the index points are not returned, it should return the default value. But instead it returns empty data. 
 How do I make sure that the default value is returned</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Index default value</title><link>https://community.appian.com/thread/84351?ContentTypeID=1</link><pubDate>Thu, 05 Aug 2021 13:48:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1098c136-0e77-4b32-8274-68d7749d6806</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I&amp;#39;ve tested it a bit and it seems like it handles most corner cases well.&amp;nbsp; I may have forgotten some of course.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Index default value</title><link>https://community.appian.com/thread/84342?ContentTypeID=1</link><pubDate>Thu, 05 Aug 2021 06:12:01 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0497b537-ab4c-486a-b893-bf6c02503ea3</guid><dc:creator>Harshit Bumb (Appyzie)</dc:creator><description>&lt;p&gt;Oh yes! How can I forget that &lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f61b.svg" title="Stuck out tongue"&gt;&amp;#x1f61b;&lt;/span&gt;&lt;br /&gt;But&amp;nbsp;I wonder, does it checks for blank string and blank list too?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Index default value</title><link>https://community.appian.com/thread/84321?ContentTypeID=1</link><pubDate>Wed, 04 Aug 2021 13:40:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:078235b4-cceb-4ba0-b73d-fc2fc6a1cd87</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="32884" url="~/discussions/f/general/21483/index-default-value/84309#84309"]using an if condition[/quote]
&lt;p&gt;And now in 21.2 they&amp;#39;ve made this even easier since we have a!defaultValue(), such things no longer need to be wrapped in an IF() statement.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Index default value</title><link>https://community.appian.com/thread/84310?ContentTypeID=1</link><pubDate>Wed, 04 Aug 2021 06:31:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f1f26cdf-c258-47b1-aedc-e3a354eece8f</guid><dc:creator>ankitab254</dc:creator><description>&lt;p&gt;Thanks everyone for your inputs. i have tried a work around, where i am doing a null check for the index array, but I was just wondering index function itself does the null check and returns the default value, but it&amp;#39;s not doing in this case.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Index default value</title><link>https://community.appian.com/thread/84309?ContentTypeID=1</link><pubDate>Wed, 04 Aug 2021 06:03:45 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fb588d3f-99f7-42ed-b0bb-ca32897cf61d</guid><dc:creator>Harshit Bumb (Appyzie)</dc:creator><description>&lt;p&gt;Hi There,&lt;/p&gt;
&lt;p&gt;In such cases, it is always best to add a null check.&amp;nbsp;&lt;br /&gt;E.g. Instead of retuning &amp;quot;Hello&amp;quot;, please return a null and then in another variable, using an if condition, add a null check to return &amp;quot;hello&amp;quot; in case the indexed property is null or does not exists.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Also, please consider creating a custom nullCheck rule that treats null, empty string, and empty list as null.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Index default value</title><link>https://community.appian.com/thread/84306?ContentTypeID=1</link><pubDate>Wed, 04 Aug 2021 01:13:30 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2ec2acbb-1554-4ac0-8923-1578dd98e472</guid><dc:creator>Raghuvaran Nagarajan</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;One of the weird behaviours of index(), When you pass empty array as index it returns all values in the array because it treats the index as a list of empty nested field names (text).&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;But if you pass empty integer array as index it returns empty.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;wherecontains() has a return type as integer array even it&amp;#39;s empty. so index will return empty.&lt;/p&gt;
&lt;p&gt;please check this snippet below.&lt;/p&gt;
&lt;p&gt;index({&amp;quot;A&amp;quot;,&amp;quot;B&amp;quot;},{},{&amp;quot;default&amp;quot;}) /*returns A,B */&lt;/p&gt;
&lt;p&gt;index({&amp;quot;A&amp;quot;,&amp;quot;B&amp;quot;},tointeger({}),{&amp;quot;default&amp;quot;}) &amp;nbsp;/*returns empty */&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Index default value</title><link>https://community.appian.com/thread/83941?ContentTypeID=1</link><pubDate>Thu, 22 Jul 2021 16:17:44 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:322cf58d-3e4e-4591-8002-e54bfe8bb837</guid><dc:creator>Selvakumar Kumarasamy</dc:creator><description>&lt;p&gt;Hi &lt;a href="/members/ankitab254"&gt;ankitab254&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The default value should be the same as that of the array elements as per the documentation.&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/11/pastedimage1626970508737v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.appian.com/suite/help/21.2/fnc_array_index.html#parameters"&gt;docs.appian.com/.../fnc_array_index.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>