Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
13 replies
Subscribers
8 subscribers
Views
4523 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
is it possible to put the below expression in query rule where condition?
ramakg
A Score Level 1
over 9 years ago
is it possible to put the below expression in query rule where condition?
month(EMP_HIRE_DATE) &"-"& year(EMP_HIRE_DATE)=year(now()) & month(now())-1
OriginalPostID-199845
OriginalPostID-199845
Discussion posts and replies are publicly visible
0
Dan Lluhi
Certified Lead Developer
over 9 years ago
I've found the best way to query based on complex conditions is to use a!queryEntity. queryEntity allows you to define logicalExpressions within the query which can combine queryFilters and more logicalExpressions. Here's a link to the documentation which explains queryEntity further:
forum.appian.com/.../System_Functions.html
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
Sure. I think you have a full date in your database that includes the day. So you have to check whether the date in DB is between (>=) the first day of the month and the last day (<=).
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
Sorry ... this works in queryEntity only. But queryEntity is so much better that you should stop using query rules.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Tim
Certified Lead Developer
over 9 years ago
What you're asking isn't possible even with queryEntity(). You would have to do you concatenation on the database side using a view and then query against it with either a query rule or queryEntity.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
=a!queryEntity(
entity: cons!MSS_ENTITY_MEETING_FLAT,
query: a!query(
logicalExpression: a!queryLogicalExpression(
operator: "AND",
filters: {
if(isnull(ri!month), null, {
a!queryFilter(
field: "createdAt",
operator: ">=",
value: datetime(year(ri!month), month(ri!month), 1, 0, 0, 0)
),
a!queryFilter(
field: "createdAt",
operator: "<=",
value: datetime(
year(eomonth(ri!month, 0)),
month(eomonth(ri!month, 0)),
day(eomonth(ri!month, 0)),
23, 59, 59)
)
}
),
a!queryFilter(
field: "cancelled",
operator: "=",
value: false
)
}
),
pagingInfo: ri!pagingInfo
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 9 years ago
@stefan: "queryEntity is so much better that you should stop using query rules." -- I'd have to disagree entirely, or at least say that's far too broad a statement - but that's a discussion for another thread: https://forum.appian.com/suite/tempo/entry/e-196692
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
I agree. But we did some performance tests etc. and decided to leave query rules behind. Expressions using queryEntity can be much better tailored to certain use cases. But this is just what we found.
The other thread is very nice ;-)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
ramakg
A Score Level 1
over 9 years ago
is it possible put the same condition in queryEntity?
sample code is :
a!queryEntity(
entity: cons!EMPLOYEE_ENTITY,
query: a!query(
selection: a!querySelection(
columns: {
a!queryColumn(field: "hiredate"),
a!queryColumn(field: "empid")
}
),
logicalExpression: a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: "hiredate",
operator: "<",
value: date(year(now()), month(now())-1, day(now()))
),
a!queryFilter(
field: "empid",
operator: "=",
value: ri!empid
)
}
),
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: -1
)
)
)
getting the below error message
Expression evaluation error at function a!queryEntity: Cannot apply operator [LESS_THAN] to field [dtCreated] when comparing to value [TypedValue[it=7,v=2016-02-10]].
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Tim
Certified Lead Developer
over 9 years ago
Use the datetime() function instead of date() as per Stefan's example
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
ramakg
A Score Level 1
over 9 years ago
is it possible to check only month and year not the date like 201603?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>