Skip to main content
April 2, 2021
Question

Equals operator returns one or all

  • April 2, 2021
  • 13 replies
  • 0 views

Hello everyone,

I'll preface this by saying I'm new to Appian, so don't assume I've tried the obvious...

I am picking up the administration of another person's app and using a text field to pull back information for a read-only grid. The expression is set to look at three different search fields in the interface and retrieve information based on one or more of these fields (three AND query filters), ignoring empty filters. The text queries are fine, but the numeric one is not and is configured as follows:

          a!queryFilter(
            field: "number",
            operator: "=",
            value: ri!rinumber
          )

This filter either matches exactly and returns just one record, or returns ALL records as though no filter were applied. I've removed my other filters from the query just in case and got the same result. Any ideas what might be causing this? Is it possible (or even logical) to wrap just this one filter in an if() to return a distinct value or nothing at all?

13 replies

mikes0011
Brainy
April 2, 2021

If your query entity is set up to "ignore empty" as you've indicated, then if you pass in nothing for ri!rinumber, it will query as if you're not filtering on that field at all.  If your use case requires you to return no results when ri!rinumber is blank, you might consider setting the query to not ignore empty filters, or alternatively (my preferred workaround) is wrapping the input in a null check and passing a value you know will be invalid (i.e. -1) - this is usually done from the parent, i.e. if my query is self-contained within an expression rule and i want to query a row by ID, but i want it to return blank (instead of trying to return every row) when the ID is blank - i'll replace blank values with -1 from there.

The Expression Guru
April 2, 2021

Thanks for the reply, Mike. To clarify, I'm really not upset about it returning everything when the field is blank - actually I prefer it. My issue is when I pass in a value that does not match - for instance, these are all 5-digit integers as defined in the DB, CDT, etc., but I enter three random letters - I need it to return an empty grid instead of all values. Hopefully that makes sense.

mikes0011
Brainy
April 2, 2021

If the rule input is of type integer (which I'm assuming, but correct me if i'm wrong), and you attempt to pass letters into it, the mandatory automatic typecasting will try to convert the letters to integer, a process which strips any letters and returns any result -- and in your case would be returning a value of null.  Mind explaining a bit more about your use case to help me understand why you're expecting to pass random letters in place of a numeric id?

The Expression Guru