Append With Items Results

Seamlessly integrate "With Items" task results into your original list.

Use case

You're dealing with nested data structures and need to extract results from tasks ran "With Items" into your original list. You want a unified, easy-to-manipulate list that includes all necessary data.

Overview

The Process With Items Results transform enables effective incorporation of "With Items" task results into your original list. It bridges the gap between the collected results and the original list, making your data manipulation tasks simpler and more efficient.


Parameters

ParameterDescriptionRequired

Base List

This is the main list to which you want your collected results to be appended.

Collected List

This is the list of results from your completed With Items task, from which the nested result.result attribute will be extracted.

Attribute Name

This is the name you'd like to set for the new attribute to be appended to the Base List.

Usage

The below scenario will attempt to illustrate how the Process With Items Results transform can be utilized to simplify With Items results collection.

Input Lists

Assume we have a base list called base_list:

base_list: [
  {
    name: "John",
    age: 30,
  },
  {
    name: "Mary",
    age: 35,
  },
]

And we ran a With Items task against this list to collect additional data from these items that's stored in a new list called collected_list that includes result.result attributes like this

collected_list: [
  {
    result: {
      result: ["golf", "reading"]
    }
  },
  {
    result: {
      result: ["cooking", "music"]
    }
  },
]

Action Parameters:

We want to extract the result.result list from each item in the collected_list and append it to each corresponding item in the base_list as a new attribute named hobbies.

base_list: base_list
collected_list: collected_list
attribute_name: hobbies

Jinja2 Equivalent:

{% set normalized_list = [item.result.result for item in my_collected_list] %}
{% for list_item in normalized_list %}
  {% do my_base_list[loop.index0].update({'hobbies': list_item}) %}
{% endfor %}

Results Output

After processing, your results will look like this:

results: [
  {
    name: "John",
    age: 30,
    hobbies: ["golf", "reading"]
  },
  {
    name: "Mary",
    age: 35,
    hobbies: ["cooking", "music"]
  },
]

Having understood the Process With Items Results transform, you're now capable of seamlessly integrating data from one list to another. Remember to carefully specify your Collected List, Base List, and Attribute Name to ensure a successful transformation.

Last updated