Empty resultset evaluation

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:

  1. Query a table
  2. When there are no results, return false 
  3. If there are results, iterate the results and return if the result set contains non blank items of a column

I had added an if condition in a!forEach expression. I am using fv!itemCount>0 condition which works fine only when there are valid results. it is not going into the false block when the resultset is emtpy.

How do i check a!queryEntity returns an empty entity/ data without any results?

Your help is much appreciated!

Please ignore any typos/syntax errors on the below snippet. 

load(
local!localCollections: a!queryEntity(
entity: cons!MY_ENTITY,
query: a!query(
logicalExpression: a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: "myPK",
operator: "=",
value:6
),
ignoreFiltersWithEmptyValues: true
),
pagingInfo:a!pagingInfo(startIndex: 1, batchSize: - 1
)
),
fetchTotalCount: true

),
a!forEach(
items:local!localCollections,
expression : if(fv!itemCount>0,
rule!GBL_isNotBlank(index(fv!item, "status", null)),
true()
)
)
)

  Discussion posts and replies are publicly visible

Parents
  • Hi There,

    You could try to add the following filter, that would help you to remove the null values:

              a!queryFilter(
                applyWhen: not(rule!GBL_isNotBlank(ri!NO_BLANK_COLUMN)),
                field: "NO_BLANK_COLUMN",
                operator: "not null",
                value: ri!NO_BLANK_COLUMN
              ),

    Hope that helps,

    Regards,

    Acacio B.

  • Acacio,

    Many thanks for your time. I figured out  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. 

    May I know how do I  find out if the items i use in a!forEach is a valid list and not a {}.  

    i had used fv!itemCount in expression of a!forEach. In the below snippt, itreturns true when the itemCount>0, but not returning false when the itemCount =0

    a!forEach(
    items:local!localCollections,
    expression : if(fv!itemCount>0,
    rule!GBL_isNotBlank(index(fv!item, "status", null)),
    false())

    any directions/pointers would be very helpful 

  • Hi Kumar, 

    What is the current value that you have in your local!localCollections?

    If I understood correctly your scenario even after apply the "Not Null" filter you still have null entries in your return?

    I'm not sure why you would need the foreach, perhaps you could use reject().

    Is your final goal to have a list of Booleans? Or the values that where found in the query?

    Sorry if I got confuse here Slight smile

Reply Children