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
4 replies
Subscribers
7 subscribers
Views
3371 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Is there a way to select a single CDT from an array of CDTs (of the same type) b
Gavin Hume
Certified Senior Developer
over 9 years ago
Is there a way to select a single CDT from an array of CDTs (of the same type) based on the value of a child element within the CDT?
As an example, if we have a web service response that includes repeating elements of type Address (a CDT), we need to be able to pick out the Address where Address.Type="MAILING" (actually we might just want Address.Postcode where Address.Type="MAILING" but if we can find the right Address section we can then get the postcode).
As a further complication this would need to return null (or at least not error) if the web service response contained no Addresses...
OriginalPostID-116430
OriginalPostID-116430
Discussion posts and replies are publicly visible
0
Tim
Certified Lead Developer
over 9 years ago
Have a look at wherecontains to see if it may help e.g. pv!Address[wherecontains({"MAILING"}, pv!Address.TYPE)].postcode
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Colin Teubner
Appian Employee
over 9 years ago
To cover your complication, you'll want to use index(index(pv!Address, wherecontains("MAILING", pv!Address.Type, null), "postcode", null) to cover the case in which the response contains no addresses.
Index function does the same thing as [1] or .postcode except that it will return the third value if the selected index doesn't exist in the array.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Colin Teubner
Appian Employee
over 9 years ago
Forgot a close parenthesis: index(index(pv!Address, wherecontains("MAILING", pv!Address.Type), null), "postcode", null)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Gavin Hume
Certified Senior Developer
over 9 years ago
Thanks for the responses, I've now got this to work using index, where and like (your responses helped point me in the right direction).
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel