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
1817 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
I have an Order CDT with a nested Item CDT (1 order can have many items).
Jason Noker
over 8 years ago
I have an Order CDT with a nested Item CDT (1 order can have many items).
I am trying to retrieve all items ordered by a specific customer.
local!orders: getOrdersByCustomerId (ri!customer.id,local!pagingInfo).data
from local!orders how can I get all of the items?
OriginalPostID-211136
OriginalPostID-211136
Discussion posts and replies are publicly visible
0
sikhivahans
over 8 years ago
@jasonn Hi, I believe something like below should do the job for you:
load(
\tlocal!orders: rule!getOrdersByCustomerId (ri!customer.id,local!pagingInfo).data,
\tlocal!items: fn!cast(
\ tfn!typeof(
\ t{type!Items()}
\ t),
\ tfn!apply(
\ tfn!index(_, "Items", {}),
\ tlocal!orders
\ t)
\t),
\t/* Replace Items in type!Items() with the name of your cdt. Replace the Items in fn!index(_, "Items", {}) with the name of the Items field in Order. */
\tlocal!items
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jason Noker
over 8 years ago
Yes! thank you.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Steven Miccile
Appian Employee
over 8 years ago
The result of the query leaves you with a list of lists due to the nested multiple CDT. Dot notation nor the index function will be able to easily grab the items as a result. The way to get the information is to flatted the nested list as outlined by the first comment.
I rarely nest data structures due to some of these cons that can outweigh the pros. If only items are desired, querying the items table directly (or a view based on foreign key structure) is an alternative.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
@jasonn No problem..!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel