Lookup mapping works for 1 record but fails for multiple records

Hi all,

I’m running into a weird behavior with a lookup step and templating.

What I’m doing

  1. Step 1 (Source / Search invoices): I fetch invoices and then group invoices by id.

When there are two invoice groups, the output looks like this:

{
  "page_of_records": [
    {
      "rows": [
        { "id": "150827" },
        { "id": "150827" },
        { "id": "150827" }
      ]
    },
    {
      "rows": [
        { "id": "150832" }
      ]
    }
  ]
}
  1. Step 2 (Lookup): I do a lookup with an additional search criteria:
  • Formula (Numeric): {billingtransaction.id} equal to {{{0.id}}}

Expected

I expect the lookup to run for both grouped invoices and return 2 results (one for id 150827 and one for 150832).

Actual behavior

  • It gives 1 result
  • The other one fails with:

Failed to generate criteria.3.searchValue from template: {{{0.id}}}. Details: "id" not defined in undefined - 1:3.

Then on the next run, the other one works (like it flips which one fails).

Important detail

If the grouping produces only one group, it works fine:

{
  "page_of_records": [
    {
      "rows": [
        { "id": "150827" },
        { "id": "150827" },
        { "id": "150827" }
      ]
    }
  ]
}

Question

Why does {{{0.id}}} work when there’s only one page_of_records entry, but fails when the grouped output contains multiple page_of_records entries?

Is {{{0.id}}} pointing at the wrong level (page vs row), or does the lookup iterate differently when there are multiple pages?

Any guidance on the correct template reference for this grouped structure would be appreciated.

What if you try {{[0].id}}?

It seems I forgot to put a $ at the top of the Rules 2 mapping.

Because of that, the second row started getting a mappedObject added at the top:

On the first page, it doesn’t include the mappedObject:

So 0.id would never work for the second page.

I changed the input field to Object, added the $, and it worked.

However, there seems to be problem with the rules 2 mapper. For example the preview output doesn’t show any updated data, so this looks like a preview bug.

That is very odd. We'll log a bug and get it fixed.