Lookup data over elements inside a nested array

Hi,

I tried doing some search on the community posts, but I couldn't find anything related to this.

I'm trying to run a lookup over the line_items of a Shopify orders export. My shopify orders export step, exports the following structure:

{
  "page_of_records": [
    {
      "record": {
        "orders": [
          {
            "id": 4847373844656,
            ...
            "line_items": [
              {
                "id": 12128799522992,
                ...
              }
            ],
            ...
          },
          {
            "id": 4847370338480,
            ...
            "line_items": [
              {
                "id": 12128770523312,
                ...
              },
              {
                "id": 12128770556080,
              }
            ],
            ...
          },

What I need to do, is, for each order, I need to go into the line_items array, and for each element in this array, I need to lookup the corresponding Item No. on my ERP item catalog.

I'm able to setup a Lookup with "One to Many" set to true, and the Path to Many = orders... But with this, my lookup is running just once, over each "order" record.

How can I arrange my lookup (or maybe what should I do to my flow) so that I have a lookup that run for each line_item inside each order?

I'm thinking that may I will need to restructure my flow, but I'm out of ideas on how I should restructure to run over the line_item elements.

 

Thanks in advance

0

Comments

4 comments
Date Votes
  • Marcelo Borges what does your flow look like? Are you getting the list of orders on the source side of the flow? If so, you just have to set your resource path to "orders", then each record will be an individual order.

    1
  • Hi Tyler Lamparter, thank you for the prompt information. I am getting a list of orders from the source side of the flow yes.... But I'm not sure I can promote the Orders node as the main node for records, I need to look into that. This actually seems like it would help me doing the lookup for the individual elements of line_items, but I think I may break something else.

    Thanks for the food for thought on this, I'll definitely consider this suggestion.

    If this suggestion cannot be used, does the interface allow for any type of One-to-Many inside a One-to-Many, or that's not possible with the currently UI?

    Just for info: Another suggestion a co-worker suggested after I posted this, is just to work on a script to bring the Items array outside together with the Orders array, and then I would work off that array on my lookup.

    Thanks again.

    0
  • Marcelo Borges what is the end goal of the flow and why can't the orders array be promoted to the main node? To specifically answer your question, one-to-many does not support nested arrays so you either need to string two flows together or write a script to bring the nested array up a level. 

    If you don't promote the order array, then you potentially could run into our 5 MB page size limit depending on how many orders are returning in your initial GET request. See help article here: https://docs.celigo.com/hc/en-us/articles/360043927292#Page_size.

    1
  • Hi Tyler, the use case is that I am batch processing records, and I needed the orders array to be kept as an array. What I ended up doing here is what my co-worker suggested: to build the array that I needed to look up on, outside of the orders array. With that, I was able to run the Lookup, one to many, based on that new array.

    Thanks for the prompt assistance on the day I was having this issue and also, for pointing out that I may run over a 5MB page with my current approach. Tks!

    1

Please sign in to leave a comment.

 

Didn't find what you were looking for?

New post