Skip to main content
Known Participant
Apr 17, 2025 8:12 AM UTC
Question

Error evaluating expression

Hi I have written this query to fetch result based on two filter criteria. When I am passing either of employeeId or Created by it throws the following error. But if I pass both employeeId and CreatedBy it works properly. Can anyone help as in what is wrong in this?

The error:

The code:

rule!NGS_queryEntityRefresh(
dataStoreEntity: cons!NGS_DSE_QPP_PERFORMANCE_TRACKER,
returnType: ri!returnType,
executeWhen: ri!executeWhen,
queryLogicalExpression: a!queryLogicalExpression(
operator: "OR",
logicalExpressions: {
a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: "employeeId",
operator: "in",
value: ri!employeeIds,
applyWhen: not(rule!NGS_isBlank(ri!employeeIds))
),
a!queryFilter(
field: "discussionTopicRefId",
operator: "in",
value: ri!discussionTopicRefIds,
applyWhen: not(rule!NGS_isBlank(ri!employeeIds))
),
a!queryFilter(
field: "discussionSubtopicRefId",
operator: "in",
value: ri!discussionSubtopicRefIds,
applyWhen: not(rule!NGS_isBlank(ri!employeeIds))
),
a!queryFilter(
field: "date",
operator: ">=",
value: ri!startDate,
applyWhen: not(rule!NGS_isBlank(ri!employeeIds))
),
a!queryFilter(
field: "date",
operator: "<=",
value: ri!endDate,
applyWhen: not(rule!NGS_isBlank(ri!employeeIds))
),
a!queryFilter(
field: "isActive",
operator: "=",
value: true,
applyWhen: not(rule!NGS_isBlank(ri!employeeIds))
),
a!queryFilter(
field: "followUpStatusRefId",
operator: "in",
value: ri!followUpStatusRefId,
applyWhen: not(rule!NGS_isBlank(ri!employeeIds))
)
},
ignoreFiltersWithEmptyValues: true
),
a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: "discussionTopicRefId",
operator: "in",
value: ri!discussionTopicRefIds,
applyWhen: not(rule!NGS_isBlank(ri!createdBy))
),
a!queryFilter(
field: "discussionSubtopicRefId",
operator: "in",
value: ri!discussionSubtopicRefIds,
applyWhen: not(rule!NGS_isBlank(ri!createdBy))
),
a!queryFilter(
field: "date",
operator: ">=",
value: ri!startDate,
applyWhen: not(rule!NGS_isBlank(ri!createdBy))
),
a!queryFilter(
field: "date",
operator: "<=",
value: ri!endDate,
applyWhen: not(rule!NGS_isBlank(ri!createdBy))
),
a!queryFilter(
field: "isActive",
operator: "=",
value: true,
applyWhen: not(rule!NGS_isBlank(ri!createdBy))
),
a!queryFilter(
field: "followUpStatusRefId",
operator: "in",
value: ri!followUpStatusRefId,
applyWhen: not(rule!NGS_isBlank(ri!createdBy))
),
a!queryFilter(
field: "createdBy",
operator: "in",
value: ri!createdBy,
applyWhen: not(rule!NGS_isBlank(ri!createdBy))
)

},
ignoreFiltersWithEmptyValues: true
)
}
),
pagingInfo: ri!pagingInfo,
fetchTotalCount: true
)

    4 replies

    Inspiring
    Apr 18, 2025 2:52 PM UTC

    Can you show how the queryEntity is configured in your NGS_queryEntityRefresh expression?

    mathieud0001
    Genius
    Apr 18, 2025 3:11 PM UTC

    Did you try simply wrapping each queryLogicalExpression with an if statement instead of putting an applyWhen on every filter?

    mikes0011
    Brainy
    Apr 18, 2025 5:51 PM UTC

    Looking through the query filters in each branch of the top-level OR clause, I can see there's an even better way to make this far more efficient.  

    All of the queryFilters between the two main branches are identical except that one of them filters on "employeeId" and the other one filters on "createdBy".  Therefore, the top-level QLE should be an "AND", it should contain all 6 of the identical query filters that match between the two, and it should contain a sub-QLE, using "OR", that has the queryFilters for createdBy and for employeeId.

    The Expression Guru
    stefanhelzle0001
    Brainy
    Apr 18, 2025 3:23 PM UTC

    This points towards a performance issue resulting in a timeout. The tomcat stdout log file will get you the details.