between

Hi,

is their any other alternative to between operator?

bcz am querying data from db.. giving different o/p in UI

same query i have used to query the data from UI so 

 a!queryFilter(
          field: "expiredDays_int",
          operator:"between",
          value: {rule!CR_CMU_DSC_getExpiredDaysInSecurityDocumentation(
            selectedItemType_txt: 1
          ).startIndex_int,
          rule!CR_CMU_DSC_getExpiredDaysInSecurityDocumentation(
            selectedItemType_txt: 31
          ).endIndex_int

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    What is wrong with "between"?

    You can just combine two filters. One with a ">" and another with a "<" operator.

  • didn't get how to write that .. how can i send the two values to filter 

    i understood your query 

    select * from xyz where id> 1 and id<30 like this but how to write in appian!

  • t function a!queryFilter [line 62]: Cannot apply operator [GREATER_THAN] to field [expiredDays_int] when comparing to value [TypedValue[it=101,v={1}]].

    a!queryEntity(
      entity: cons!CR_CMU_ENTITY_DU_MONITORING,
      query: a!query(
        logicalExpression: a!queryLogicalExpression(
          operator: "AND",
          filters: {
            a!queryFilter(
              field: "expiredDays_int",
              operator: ">",
              value: {
                rule!CR_CMU_DSC_getExpiredDaysInSecurityDocumentation(
                  selectedItemType_txt: 1
                ).startIndex_int
              }
            ),
            a!queryFilter(
              field: "expiredDays_int",
              operator: "<",
              value: {
                rule!CR_CMU_DSC_getExpiredDaysInSecurityDocumentation(
                  selectedItemType_txt: 30
                ).endIndex_int
              }
            )
          },
          ignoreFiltersWithEmptyValues: true
        ),
        pagingInfo: ri!pagingInfo
      ),
      fetchTotalCount: true()
    )

  • 0
    Certified Lead Developer
    in reply to KM

    Seems like the value is a list. This must be a single value.

  • 0
    Appian Employee
    in reply to KM

    Try the below snippet:

    a!queryEntity(
    entity: cons!CR_CMU_ENTITY_DU_MONITORING,
    query: a!query(
    logicalExpression: a!queryLogicalExpression(
    operator: "AND",
    filters: {
    a!queryFilter(
    field: "expiredDays_int",
    operator: ">",
    value: cast(
    typeof(tointeger(null)),
    rule!CR_CMU_DSC_getExpiredDaysInSecurityDocumentation(selectedItemType_txt: 1).startIndex_int
    )
    ),
    a!queryFilter(
    field: "expiredDays_int",
    operator: "<",
    value: cast(
    typeof(tointeger(null)),
    rule!CR_CMU_DSC_getExpiredDaysInSecurityDocumentation(selectedItemType_txt: 30).endIndex_int
    )
    )
    },
    ignoreFiltersWithEmptyValues: true
    ),
    pagingInfo: ri!pagingInfo
    ),
    fetchTotalCount: true()
    )

    A couple of things to note here:

    1. Curly braces in below statement indicates it's an array.

    value: {
    rule!CR_CMU_DSC_getExpiredDaysInSecurityDocumentation(
    selectedItemType_txt: 30
    ).endIndex_int
    }

    It's like writing your SQL as below which obviously results in an error (Appian presents it similar to what you have in your question): 

    select * from xyz where id > {1}

    2. I have used the cast function to ensure your rule returns a scalar value but not a list. If your rule is returning a scalar value, then you can write as below too:

    a!queryFilter(
    field: "expiredDays_int",
    operator: "<",
    value: rule!CR_CMU_DSC_getExpiredDaysInSecurityDocumentation(selectedItemType_txt: 30).endIndex_int
    )