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

  • No dice, unfortunately. It sounds like I may need to look at redesigning things as you both mentioned. Do you happen to have a link to something that would let me read up on your proposed design so I don't take up anymore time from your days?

  • Strange.. As Mike mentions, you would create 2 new expression rules, 1 for each a!queryEntity() that is called to set local!idQry and local!launchQry.  Configure them with the necessary inputs and in your code above, call the new expression rules into the local variables instead of having the queryEntity calls within the parent rule itself.  This will allow you to test each separately, creating different test cases to verify outputs without having to test them together in one expression as above.

    Additionally the query for local!launchQry can likely be simplified by removing the if check for empty filters and allowing the ignoreFiltersWithEmptyValues to handle that for you. Such as:

    Rule 1:

    a!queryEntity(
      entity: cons![constant],
      query: a!query(
        selection: a!querySelection(
          columns: {
            a!queryColumn(field: "id"),
            a!queryColumn(field: "owner"),
            a!queryColumn(field: "project"),
            a!queryColumn(field: "projectno")
          }
        ),
        logicalExpression: a!queryLogicalExpression(
          ignoreFiltersWithEmptyValues: true(),
          operator: "AND",
          filters: {
            a!queryFilter(
              field: "project",
              operator: "includes",
              value: ri!project
            ),
            a!queryFilter(
              field: "projectno",
              operator: "=",
              value: ri!Number
            ),
            a!queryFilter(
              field: "owner",
              operator: "=",
              value: ri!owner
            ),
    
          }
        ),
        pagingInfo: a!pagingInfo(1, - 1)
      )
    )

    Rule 2, simplified by removing the if(): (note local!IDs is changed to a rule input)

    a!queryEntity(
      entity: cons![Constant2],
      query: a!query(
        logicalExpression: a!queryLogicalExpression(
          ignoreFiltersWithEmptyValues: true(),
          operator: "AND",
          filters: {
            a!queryFilter(
              field: "GoLive",
              operator: "=",
              value: tostring(ri!GoLive)
            ),
            a!queryFilter(
              field: "createdon",
              operator: ">",
              value: ri!date1
            ),
            a!queryFilter(
              field: "createdon",
              operator: "<",
              value: ri!date2
            ),
            a!queryFilter(
              field: "launchname",
              operator: "includes",
              value: ri!launchName
            ),
            a!queryFilter(
              field: "PM",
              operator: "in",
              value: ri!pm
            ),
            a!queryFilter(
              field: "launchstatus",
              operator: "in",
              value: if(
                contains(
                  ri!launchStatus,
                  cons![Constant2][1]
                ),
                append(ri!launchStatus, ""),
                ri!launchStatus
              )
            ),
            a!queryFilter(
              field: "createdon",
              operator: "includes",
              value: tostring(ri!createdOn)
            ),
            /*project info*/
            a!queryFilter(
              field: "id",
              operator: "in",
              value: ri!IDs /* changed to rule input from local */
            )
    
          }
        ),
        pagingInfo: a!pagingInfo(1, -1)
      ),
      fetchTotalCount: true
    )

    Feel free to give that a try and post your configuration back here if you continue to have issues!

  • Following up on this one, instead of trying to make an old form work I decided to re-create it instead using some of the best practices you both recommended above (namely letting Appian handle what it could without unnecessary code, including ignoreFieldsWithEmptyValues). There is still a bit of a disconnect with using the IN or INCLUDES operator with integer values, but I've gotten around this by using "=" and a length validation on the field. If it does not match then it returns an empty grid with a message indicating the value was not found. This is good enough for me.

    Thank you both again for your time.