Unable to fetch data using query entity

I am trying to fetch the data using intital values from the search 

Ex. If Package ID is 10825 then I can type 10 or 25 etc. and should get complete list of package id containing those numbers displayed in search result

i tried using IN and INCLUDES but getting error and it is a wired thing can someone help i am using appian 17.4 

a!queryEntity(
entity: cons!TMOS_ETY_WF_EXEC_AUDIT,
query: a!query(
filter: a!queryFilter(
field: "packageID",
operator: "INCLUDES",
value: ri!packageID
),
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: - 1
)
)
)

error:-

Expression evaluation error at function a!queryEntity: Cannot apply operator [INCLUDES] to field [packageID] when comparing to value [TypedValue[it=101,v={4}]].

  Discussion posts and replies are publicly visible

Parents
  • The "INCLUDES" operator is intended for comparing text, so it wouldn't be expected to work on integer data (which I assume your "packageID" is).  "IN" should work, but is used for exact matches against an array, i.e. you'd query "IN" and pass in an array i.e. {11, 22, 33}, and any packages with an ID of 11, 22, or 33 (but not "7225") would be returned.

    Assuming I'm correct about packageID's type, and if you really need to do an "INCLUDES" search against it from an interface, for example, then you should be able to create a View that is basically a recreation of that table but with the addition of an additional column (i.e. "packageIdText") where you typecast the original packageID to text.  If you get that working, and create a query entity against that view instead of the table you were originally querying, you should be able to do an "INCLUDES" query on the new text-type column.

  • its not necessary to use INCLUDES although if i use IN it is not fetching the package id starting with 1 or 2 or 3 or anothing 

    code below 

    if(
    rule!TMOS_isEmpty(
    ri!packageID
    ),
    {},
    index(
    a!queryEntity(
    entity: cons!TMOS_ETY_WF_EXEC_AUDIT,
    query: a!query(
    filter: a!queryFilter(
    field: "packageID",
    operator: "IN",
    value: ri!packageID
    ),
    pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: - 1
    )

    packageID(array type-integer)

  • its not necessary to use INCLUDES although if i use IN it is not fetching the package id starting with 1 or 2 or 3 or anothing

    The use case you're describing does require INCLUDES, though.  That's what I was explaining in my prior answer.  IN does something completely different -- it would never give you the result you're currently thinking of, as it finds exact matches within an array of query inputs.

  • So as per my understanding you are suggesting that we have to use includes function to get the expected result by adding a column in DB which would be of type text and a replica of the package id which is int 

Reply Children