I have an Order CDT with a nested Item CDT (1 order can have many items).

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

Parents
  • @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
    )
Reply
  • @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
    )
Children
No Data