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
+1
person also asked this
people also asked this
Replies
11 replies
Subscribers
5 subscribers
Views
11646 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Reports
Compare Joined String to an Array in a Query Filter
Kyle Jorgensen
over 7 years ago
I am trying to compare a field that is a joined array of customer locations (ex: "Factory A; Factory X; Factory Y") to an array locations put in as a filter (user selects "Factory X"). Essentially what I would like to have happen is if any part of this array {"Factory X", "Factory Z"} is present in this field "Factory A; Factory X; Factory Y" then I'd like to return that record.
Is this possible?
OriginalPostID-259947
Discussion posts and replies are publicly visible
0
vinayakb
over 7 years ago
you can try using wherecontains function, it will give you array index of the matching value
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Sally Mason
Appian Employee
over 7 years ago
More information on wherecontains() -
forum.appian.com/.../Array_Functions.html
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Kyle Jorgensen
over 7 years ago
Can wherecontains() be used within a a!queryFilter()?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Raviteja Varma Jampana
A Score Level 2
over 7 years ago
As far as i understood, you will provide input as single string "Factory A; Factory X; Factory Y" and you are expecting to search any matches which have any of those factories. if that is the case you code must be like as follows
local!searchItems:fn!split("FACTORY A;FACTORY B;FACTORY C",";"),
/*-----
a!queryEntity(
entity:----
a!query(
-----
*/
logicalExpression:if(rule!APN_isEmpty(local!searchItems),{},a!queryLogicalExpression(
operator: "OR",
filters: {
a!applyComponents( a!queryFilter(
field: "field",
operator: "=",
value: _
),local!searchItems)
}
)
You can apply any number of query filters on same field with proper conditions it works. Let me know if you need any help.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Raviteja Varma Jampana
A Score Level 2
over 7 years ago
Instead of "=" you can use "includes" if you want to get any partial matches too
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Sally Mason
Appian Employee
over 7 years ago
In the query rule, set up rule inputs to contain the value you seek to use in the Query Convictions with the operator "includes"?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Kyle Jorgensen
over 7 years ago
@ravitejavj, hmm so loop a queryFilter using a!applyComponents; I'll try that out.
@Sally Mason, I've tried using the operator includes, but it has trouble with an string array as the value parameter, I get the error below:
"Expression evaluation error in rule 'pd_getopportunitiesforbudgetreport' at function a!queryEntity: Cannot apply operator [INCLUDES] to field [customerFab] when comparing to value [TypedValue[it=103,v={Intel - F42}]]."
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Raviteja Varma Jampana
A Score Level 2
over 7 years ago
Yes, i used a!applyComponents on queryFilters in past and it works. Regarding error, you need to do typecasting to avoid it.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
georgej
over 7 years ago
Can't we just us the "in" operator with ri!inputValues defined as "Array"
a!queryEntity(
entity:cons!XXXX,
query:a!query(
filter:a!queryFilter(
field:"FLD1",
operator:"in",
value:ri!inputValues
),
pagingInfo:rule!genericPagingInfoAll()
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Tyler Criste
Appian Employee
over 7 years ago
Kyle - I think in this case you would need to use Reviteja's idea of looping over your fabs to create one query filter for each. Then your logical expression would use OR logic, so that you'd get results where either the string includes Fab1 OR it includes Fab 2.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>