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
5 replies
Subscribers
8 subscribers
Views
3593 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Hi All, I have created a query Entity that fetches data from a view.
rishub356
over 9 years ago
Hi All,
I have created a query Entity that fetches data from a view. I am facing issue when the query entity has blank inputs & it tries to fetch all the values. How can I make sure to return no values when the input is null. Below s the query entity code:
= a!queryEntity(
entity: cons!LISTING,
query: a!query(
logicalExpression: if(
and(
rule!APN_isBlank(
ri!Num
),
rule!APN_isBlank(
ri!secondID
),
rule!APN_isBlank(
ri!Code
),
rule!APN_isBlank(
ri!D
)
),
null,
a!queryLogicalExpression(
operator: "AND",
filters: {
if(
rule!APN_isBlank(
ri!Num
),
{},
a!queryFilter(
field: "Num",
operator: "=",
value: ri!Num
)
),
if(
rule!APN_isBlank(...
OriginalPostID-208504
OriginalPostID-208504
Discussion posts and replies are publicly visible
0
rishub356
over 9 years ago
...
ri!Code
),
{},
a!queryFilter(
field: "Code",
operator: "=",
value: ri!Code
)
),
if(
rule!APN_isBlank(
ri!secondID
),
{},
a!queryFilter(
field: "secondID",
operator: "=",
value: ri!secondID
)
),
if(
rule!APN_isBlank(
ri!ID
),
{},
a!queryFilter(
field: "ID",
operator: "=",
value: ri!ID
)
),
a!queryFilter(
field: "parentID",
operator: "is null"
)
}
)
),
pagingInfo: rule!PDIM_genericPagingInfo_All()
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jacob Cohen - Project Leader - Macedon Technologies
over 9 years ago
You can put your if around the entire queryEntity instead.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
Put all the checks around your query and return "todatasubset({})" if they fail. This way you are consistent in the returned value.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
jagadeesh
Certified Lead Developer
over 9 years ago
you can put if condition before applying filter
just like
a!queryEntity(
entity: cons!COB_DATASTORE_CUSTOMER_CASE,
query: a!query(
selection: if(
rule!COB_verifyIsNullorEmpty(
ri!selectionColumns
),
{},
a!querySelection(
columns: apply(
rule!COB_dynamicQueryColumn,
{
ri!selectionColumns
}
)
)
),
pagingInfo: if(
isnull(
ri!pagingInfo
),
a!pagingInfo(
startIndex: 1,
batchSize: - 1
),
ri!pagingInfo
),
logicalExpression: if(
and(
rule!COB_verifyIsNullorEmpty(
ri!Id
),
rule!COB_verifyIsNullorEmpty(
ri!Name
),
rule!COB_verifyIsNullorEmpty(
ri!customerId
),
rule!COB_verifyIsNullorEmpty(
ri!caseStatus
)
),
null,
a!queryLogicalExpression(
operator: "AND",
filters: {
if(
rule!COB_verifyIsNullorEmpty(
ri!Id
),
{},
a!queryFilter(
field: "Id",
operator: "=",
value: ri!Id
)
),
if(
rule!COB_verifyIsNullorEmpty(
ri!Name
),
{},
a!queryFilter(
field: "Name",
operator: "includes",
value: ri!Name
)
),
if(
rule!COB_verifyIsNullorEmpty(
ri!customerId
),
{},
a!queryFilter(
field: "CustomerId",
operator: "=",
value: ri!customerId
)
),
if(
rule!COB_verifyIsNullorEmpty(
ri!caseStatus
),
{},
a!queryFilter(
field: "CaseStatus",
operator: "=",
value: ri!caseStatus
)
)
}
)
)
)
).data
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rishub356
over 9 years ago
Thanks All. Using if condition in SAIL code fixed the issue.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel