Unable to retrieve data from queryEntity for a date range

Unable to retrieve data from queryEntity for a date range. The below code is not working and instead throwing an error that "between" operator cannot be used. Please advise how to fix it.

local!chartDatasubset: a!queryEntity(
entity: cons!NSARequest_Entity_Cons,
query: a!query(
aggregation: a!queryAggregation(
aggregationColumns: {
a!queryAggregationColumn(field: "Status", alias: "Status", isGrouping: true),
a!queryAggregationColumn(field: "SubmittedDate", alias: "SubmittedDate", isGrouping: true),
a!queryAggregationColumn(field: "Id", aggregationFunction: "COUNT")
}
),
filter: a!queryFilter(
field: "SubmittedDate",
operator: "between",
value: { if(isnull(ri!StartDate), today(), ri!StartDate), if(isnull(ri!EndDate), today(), ri!EndDate) }
),
pagingInfo: local!chartPagingInfo
)
),

 

 

Initially had an expression rule below which used to be working in 18.3 version. Not sure if in new 18.4 version it isn't. Please advise.

 

with(
local!chartPagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: -1,
sort: a!sortInfo(
field: "SubmittedDate",
ascending: true
)
),
a!queryEntity_18r3(
entity: cons!NSARequest_Entity_Cons,
query: a!query(
filter: {
a!queryFilter(
selection: "",
field: "SubmittedDate",
operator: "between",
value: { ri!StartDate, ri!EndDate }
)
},
pagingInfo: local!chartPagingInfo
)
)
)

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    A Score Level 2
    in reply to anushas0002

    looks like the Filter Parameter Between is expecting both inputs are of type Date Time, Please change it to Date Time and then Test It.

    { if(isnull(ri!StartDate), now(), ri!StartDate), if(isnull(ri!EndDate), now(), ri!EndDate) }

  • 0
    Certified Lead Developer
    in reply to anushas0002
    Hi your rule input i.e. ri!startDate and ri!endDate should match with the type of your DB column data type i.e. submittedDate (Date and Time).

    Hence to resolve this you have following ways:

    1. [Recommended] change your input type to Date and Time in Appian and pass the respective value to it and also make sure that you are handling the null values properly.

    2. [Not Recommended] If you don't want to change your input type in such case, you need to enclose ri! startDate and ri!endDate with todatetime() function as shown below:
    value: {todatetime(ri!startDate), todatetime(ri!endDate)}

    -- This will convert your Date input value to Date and Time. But i would not recommend to go for this approach, as the Approach 1 stands better here.

    3. [Not Recommended] If you don't want to change your input type in such case an another approach could be: Alter the Database column type to Date and re-map your CDT and verify your data store (to avoid any mapping issues). But i would not recommend to go for this approach, as the Approach 1 stands better here.

    Hope this will help you.