Equals operator returns one or all

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?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    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.

  • 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.

  • 0
    Certified Lead Developer
    in reply to robinh0003

    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?

Reply
  • 0
    Certified Lead Developer
    in reply to robinh0003

    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?

Children
  • Ok, the auto-typecasting explanation makes sense. I'm not intending to pass character values, merely using it to demonstrate my issue. The same thing happens if I pass more or less than 5 integers or if I pass five integers which have no match in the database - it gives me all the results. If I pass five integers which do match a value in the database then my read-only grid filters just like it's supposed to and returns that one record.