<?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>Empty resultset evaluation</title><link>https://community.appian.com/discussions/f/data/21547/empty-resultset-evaluation</link><description>Hi, 
 I am new to Appian and in learning phase. I would like to know how do I treat empty resultSets while using using a!forEach combined with a!queryEntity 
 
 My requirements: 
 
 Query a table 
 When there are no results, return false 
 If there are</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Empty resultset evaluation</title><link>https://community.appian.com/thread/84258?ContentTypeID=1</link><pubDate>Mon, 02 Aug 2021 22:24:57 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:39181f61-3be6-4322-9b81-4bc585052d94</guid><dc:creator>ramkumars0001</dc:creator><description>&lt;p&gt;&lt;a href="/members/selvakumark"&gt;Selvakumar Kumarasamy&lt;/a&gt; Thanks, this is exactly is what i am looking for.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for your time and help. Much appreciated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Empty resultset evaluation</title><link>https://community.appian.com/thread/84257?ContentTypeID=1</link><pubDate>Mon, 02 Aug 2021 22:24:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cecd8faa-0dca-4db4-8ed2-4d170a83b037</guid><dc:creator>ramkumars0001</dc:creator><description>&lt;p&gt; Final goal is to return the list of booleans . I forgot the and in the code snippet.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Objective is to return false when there are no records returned and return true/false if there are records and one of the column is non-blank.&lt;/p&gt;
&lt;p&gt;The solution given by &lt;a href="/members/selvakumark"&gt;Selvakumar Kumarasamy&lt;/a&gt; is what i am looking for&lt;/p&gt;
&lt;p&gt;index(local!localCollections, &amp;quot;totalCount&amp;quot;, 0) = 0&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you so much for your time and help. Much appreciated&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Empty resultset evaluation</title><link>https://community.appian.com/thread/84222?ContentTypeID=1</link><pubDate>Mon, 02 Aug 2021 03:00:58 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:05d8a172-d4c2-4e1e-998a-14d18b77abce</guid><dc:creator>Selvakumar Kumarasamy</dc:creator><description>&lt;p&gt;Hi &lt;a href="/members/ramkumars0001"&gt;ramkumars0001&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;The query entity will usually return the results in a data subset type. I could see that you&amp;#39;re typically giving the data subset as the input to the forEach(). The function has the ability to operate on the data inside the data subset &amp;amp; if it has no data, then the function will not even call the expression defined. Hence you might not be getting the output.&lt;/p&gt;
&lt;p&gt;Below code snippet might help you to return false if there are no data(this is one way, there are other ways too).&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!localCollections: a!queryEntity(
    entity: cons!MY_ENTITY,
    query: a!query(
      logicalExpression: a!queryLogicalExpression(
        operator: &amp;quot;AND&amp;quot;,
        filters: {
          a!queryFilter(
            field: &amp;quot;myPK&amp;quot;,
            operator: &amp;quot;=&amp;quot;,
            value:6
            )
        },
        ignoreFiltersWithEmptyValues: true
      ),
      pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 10)
    ),
    fetchTotalCount: true
  ),
  if(
    index(local!localCollections, &amp;quot;totalCount&amp;quot;, 0) = 0,
    false(),
    a!forEach(
      items: local!localCollections,
      expression: if(
        fv!itemCount &amp;gt; 0,
        rule!GBL_isNotBlank(index(fv!item, &amp;quot;status&amp;quot;, null)),
        true()
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;But I&amp;#39;m&amp;nbsp;still not getting your specific use case - whether it is to return a boolean array (or) list of items that are not null?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Empty resultset evaluation</title><link>https://community.appian.com/thread/84221?ContentTypeID=1</link><pubDate>Mon, 02 Aug 2021 01:45:21 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8b22cb16-abee-4dd7-a733-397f6396e1fb</guid><dc:creator>Acacio Barrado</dc:creator><description>&lt;p&gt;Hi Kumar,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What is the current value that you have in your local!localCollections?&lt;/p&gt;
&lt;p&gt;If I understood correctly your scenario even after apply the &amp;quot;Not Null&amp;quot; filter you still have null entries in your return?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure why you would need the foreach, perhaps you&amp;nbsp;could use reject().&lt;/p&gt;
&lt;p&gt;Is your final goal to have a list of Booleans? Or the values that where found in the query?&lt;/p&gt;
&lt;p&gt;Sorry if I got confuse here &lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Empty resultset evaluation</title><link>https://community.appian.com/thread/84220?ContentTypeID=1</link><pubDate>Mon, 02 Aug 2021 01:22:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fc44d1b5-85be-4a3b-9791-7846eda2c3a4</guid><dc:creator>ramkumars0001</dc:creator><description>&lt;p&gt;Acacio,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Many thanks for your time. I figured out&amp;nbsp; after i posted and I have already added the operator not null in operator. The problem is when the user searches for a where clause, chances are it may not match any results and will return no results.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;May I know how do I&amp;nbsp; find out if the items i use in a!forEach is a valid list and not a {}.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;i had used fv!itemCount in expression of a!forEach. In the below snippt, itreturns true when the itemCount&amp;gt;0,&amp;nbsp;but not returning false when the itemCount =0&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;a!forEach(&lt;/span&gt;&lt;br /&gt;&lt;span&gt;items:local!&lt;/span&gt;&lt;span&gt;localCollections&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;expression : if(fv!itemCount&amp;gt;0,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;rule!GBL_isNotBlank(index(fv!item, &amp;quot;status&amp;quot;, null)),&lt;/span&gt;&lt;br /&gt;&lt;span&gt;false()&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;any directions/pointers would be very helpful&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Empty resultset evaluation</title><link>https://community.appian.com/thread/84219?ContentTypeID=1</link><pubDate>Mon, 02 Aug 2021 00:22:47 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:80afed72-edfb-449a-b417-f1ba5cb528b9</guid><dc:creator>Acacio Barrado</dc:creator><description>&lt;p&gt;Hi There,&lt;/p&gt;
&lt;p&gt;You could try to add the following filter, that would help you to remove the null values:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;          a!queryFilter(
            applyWhen: not(rule!GBL_isNotBlank(ri!NO_BLANK_COLUMN)),
            field: &amp;quot;NO_BLANK_COLUMN&amp;quot;,
            operator: &amp;quot;not null&amp;quot;,
            value: ri!NO_BLANK_COLUMN
          ),&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Hope that helps,&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Acacio B.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>