Filtering array through multiple collections/arrays

I have a module that aggregates an array, I am trying to iterate through that array, but filter my results using some criteria. Specifically, I want to filter the array where the custom field CRM-Company id = 86883jmgc.

I’m trying to use the map function, but can’t seem to figure out how to filter my array. Can anyone provide a suggestion given the data structure that I am showing in the attached image?

1 Like

Welcome to the Make community!

You can put a filter before the aggregator module, so that only the filtered items reach the aggregator. This is much easier than filtering the items afterwards.

To allow us to assist you with your scenario, please provide the following:

1. Relevant Screenshots

Please share screenshots of your scenario, any error messages, relevant module fields, and filters in question? It would really help other community members to see what you’re looking at.

2. Scenario Blueprint

Please export the scenario blueprint file to allow others to view the mapped variables in the module fields. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

3. Output Bundles of Modules

Please provide the output bundles of the modules by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.

Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

@samliew


P.S.: Did you know, the concepts of about 70% of questions asked on this forum are already covered in the Make Academy. Investing some effort into it will save you lots of time and frustration using Make later!

Thank you so much for the response, I didn’t think to include so much detail. I think the suggestion of filtering before the aggregator worked. Here’s a screenshot of the overall scenario:

It does the following:

  1. Watches for a status change on my Company list
  2. Gets the details of the task that has changed
  3. Lists all tasks on the Contacts list, filters that list where Company Name matches the Company the contact is associated with
  4. Aggregate the array
  5. Iterate across the array
  6. Edit the tasks to update details about the Company on the Contacts task

I have attached a json of the scenario blueprint. Here is the output of the list all tasks module:

[
    {
        "id": "86883jhgz",
        "custom_id": null,
        "custom_item_id": 1001,
        "name": "Steph Curry",
        "text_content": "",
        "description": "",
        "status": {
            "status": "Open",
            "id": "p90110131594_BQHW4Q7x",
            "color": "#87909e",
            "type": "open",
            "orderindex": 0
        },
        "orderindex": "119418068.00000000000000000000000000000000",
        "date_created": "2024-04-04T14:59:53.649Z",
        "date_updated": "2024-08-13T18:53:02.397Z",
        "date_closed": null,
        "date_done": null,
        "archived": false,
        "creator": {
            "id": 6357496,
            "username": "Robert Curley",
            "color": "#757380",
            "email": "rcurley@insigniaenv.com",
            "profilePicture": null
        },
        "assignees": [],
        "group_assignees": [],
        "watchers": [
            {
                "id": 6357496,
                "username": "Robert Curley",
                "color": "#757380",
                "initials": "RC",
                "email": "rcurley@insigniaenv.com",
                "profilePicture": null
            },
            {
                "id": 30047465,
                "username": "ClickUp Admin",
                "color": "#595d66",
                "initials": "CA",
                "email": "twp@insigniaenv.com",
                "profilePicture": null
            }
        ],
        "checklists": [],
        "tags": [],
        "parent": null,
        "priority": null,
        "due_date": null,
        "start_date": null,
        "points": null,
        "time_estimate": 0,
        "custom_fields": {
            "CRM-Company": [
                {
                    "id": "86883fdb4",
                    "name": "Golden State Warriors",
                    "status": "target",
                    "color": "#e16b16",
                    "custom_type": 1002,
                    "team_id": "4755811",
                    "deleted": false,
                    "url": "https://app.clickup.com/t/86883fdb4",
                    "access": true
                }
            ],
            "CRM-Address": {
                "location": {
                    "lat": 37.7680183,
                    "lng": -122.3878772
                },
                "place_id": "ChIJvTaOg8Z_j4ARCdO8LroPfBA",
                "formatted_address": "1 Warriors Way, San Francisco, CA 94158, USA"
            },
            "CRM-Phone": "+1 415 555 4545",
            "CRM-Email": "scurry@warriors.com",
            "CRM-Title": "Champ",
            "CRM-Projects": [
                {
                    "id": "8689b13hj",
                    "name": "2025 NBA Finals",
                    "status": "Open",
                    "color": "#87909e",
                    "custom_type": 1004,
                    "team_id": "4755811",
                    "deleted": false,
                    "url": "https://app.clickup.com/t/8689b13hj",
                    "access": true
                },
                {
                    "id": "86883jggg",
                    "name": "Chase Center Upgrade Project",
                    "status": "delayed",
                    "color": "#f8ae00",
                    "custom_type": 1004,
                    "team_id": "4755811",
                    "deleted": false,
                    "url": "https://app.clickup.com/t/86883jggg",
                    "access": true
                }
            ],
            "CRM-Opportunities": [
                {
                    "id": "86883jmad",
                    "name": "Stanley Cup 2040",
                    "status": "cold",
                    "color": "#4466ff",
                    "custom_type": 1005,
                    "team_id": "4755811",
                    "deleted": false,
                    "url": "https://app.clickup.com/t/86883jmad",
                    "access": true
                }
            ]
        },
        "dependencies": [],
        "linked_tasks": [],
        "locations": [],
        "team_id": "4755811",
        "url": "https://app.clickup.com/t/86883jhgz",
        "sharing": {
            "public": false,
            "public_share_expires_on": null,
            "public_fields": [
                "assignees",
                "priority",
                "due_date",
                "content",
                "comments",
                "attachments",
                "customFields",
                "subtasks",
                "tags",
                "checklists",
                "coverimage"
            ],
            "token": null,
            "seo_optimized": false
        },
        "permission_level": "create",
        "list": {
            "id": "901100952151",
            "name": "CRM-Contacts",
            "access": true
        },
        "project": {
            "id": "90110442401",
            "name": "hidden",
            "hidden": true,
            "access": true
        },
        "folder": {
            "id": "90110442401",
            "name": "hidden",
            "hidden": true,
            "access": true
        },
        "space": {
            "id": "90110131594"
        },
        "custom_fields_original": [
            {
                "id": "57d1e2a8-bf1e-4698-a901-4ed5674c9efb",
                "name": "CRM-Company",
                "type": "list_relationship",
                "type_config": {
                    "fields": [
                        {
                            "name": "CRM-Company Type",
                            "field": "cf_7774c83b-ad8a-4666-b4a3-a04183bfd5cb",
                            "width": 100,
                            "hidden": false
                        }
                    ],
                    "subcategory_id": "901100952144",
                    "linked_subcategory_access": true,
                    "subcategory_inverted_name": "CRM-Companies"
                },
                "date_created": "2024-04-04T03:00:10.928Z",
                "hide_from_guests": false,
                "value": [
                    {
                        "id": "86883fdb4",
                        "name": "Golden State Warriors",
                        "status": "target",
                        "color": "#e16b16",
                        "custom_type": 1002,
                        "team_id": "4755811",
                        "deleted": false,
                        "url": "https://app.clickup.com/t/86883fdb4",
                        "access": true
                    }
                ],
                "required": false
            },
            {
                "id": "8a004126-a7cd-44ff-b0e2-d57d850641cf",
                "name": "CRM-Company Acronym",
                "type": "short_text",
                "type_config": {},
                "date_created": "2024-04-04T02:54:21.459Z",
                "hide_from_guests": false,
                "required": false
            },
            {
                "id": "3d22782c-2ea1-49dc-86e9-22ba000aff40",
                "name": "CRM-Company Type",
                "type": "short_text",
                "type_config": {
                    "options": [
                        {
                            "id": "a01a6f15-0958-4a4e-b239-750561609d82",
                            "name": "Client",
                            "color": null,
                            "orderindex": 0
                        },
                        {
                            "id": "5a5eee19-f786-43c9-96d2-5e4223580c90",
                            "name": "Teaming Partner",
                            "color": null,
                            "orderindex": 1
                        },
                        {
                            "id": "3d3b650a-c0ce-4688-9bf3-6755ad3a5c46",
                            "name": "Prospect",
                            "color": null,
                            "orderindex": 2
                        }
                    ]
                },
                "date_created": "2024-04-04T20:10:16.471Z",
                "hide_from_guests": false,
                "required": false
            },
            {
                "id": "0ac23c05-edee-4e17-96fe-9183187ee320",
                "name": "CRM-Address",
                "type": "location",
                "type_config": {},
                "date_created": "2024-04-04T02:55:54.905Z",
                "hide_from_guests": false,
                "value": {
                    "location": {
                        "lat": 37.7680183,
                        "lng": -122.3878772
                    },
                    "place_id": "ChIJvTaOg8Z_j4ARCdO8LroPfBA",
                    "formatted_address": "1 Warriors Way, San Francisco, CA 94158, USA"
                },
                "required": false
            },
            {
                "id": "307ab56d-83f9-4246-8ad1-e5e8b8ba6e19",
                "name": "CRM-Phone",
                "type": "phone",
                "type_config": {},
                "date_created": "2024-04-04T03:06:28.931Z",
                "hide_from_guests": false,
                "value": "+1 415 555 4545",
                "required": false
            },
            {
                "id": "5d51464f-2d3c-4bf7-9bf8-575b3ecce978",
                "name": "CRM-Email",
                "type": "email",
                "type_config": {},
                "date_created": "2024-04-04T03:06:55.042Z",
                "hide_from_guests": false,
                "value": "scurry@warriors.com",
                "required": false
            },
            {
                "id": "11ced288-c852-4e62-8f4e-ee836a36a815",
                "name": "CRM-Title",
                "type": "short_text",
                "type_config": {},
                "date_created": "2024-04-04T03:07:11.537Z",
                "hide_from_guests": false,
                "value": "Champ",
                "required": false
            },
            {
                "id": "d4c7ac96-31a4-447c-9dfd-97e3dfad0965",
                "name": "CRM-Projects",
                "type": "list_relationship",
                "type_config": {
                    "fields": [
                        {
                            "field": "status",
                            "width": 100,
                            "hidden": false,
                            "relationship": "d4c7ac96-31a4-447c-9dfd-97e3dfad0965"
                        },
                        {
                            "field": "assignee",
                            "width": 100,
                            "relationship": "d4c7ac96-31a4-447c-9dfd-97e3dfad0965"
                        }
                    ],
                    "subcategory_inverted_name": "CRM-Projects",
                    "subcategory_id": "901100952164",
                    "linked_subcategory_access": true
                },
                "date_created": "2024-04-04T03:16:14.252Z",
                "hide_from_guests": false,
                "value": [
                    {
                        "id": "8689b13hj",
                        "name": "2025 NBA Finals",
                        "status": "Open",
                        "color": "#87909e",
                        "custom_type": 1004,
                        "team_id": "4755811",
                        "deleted": false,
                        "url": "https://app.clickup.com/t/8689b13hj",
                        "access": true
                    },
                    {
                        "id": "86883jggg",
                        "name": "Chase Center Upgrade Project",
                        "status": "delayed",
                        "color": "#f8ae00",
                        "custom_type": 1004,
                        "team_id": "4755811",
                        "deleted": false,
                        "url": "https://app.clickup.com/t/86883jggg",
                        "access": true
                    }
                ],
                "required": false
            },
            {
                "id": "997e1973-177d-4d43-891b-ecf858f6b3ec",
                "name": "CRM-Opportunities",
                "type": "list_relationship",
                "type_config": {
                    "fields": [],
                    "subcategory_id": "901100952215",
                    "linked_subcategory_access": true,
                    "subcategory_inverted_name": "CRM-Opportunities"
                },
                "date_created": "2024-04-04T03:26:52.831Z",
                "hide_from_guests": false,
                "value": [
                    {
                        "id": "86883jmad",
                        "name": "Stanley Cup 2040",
                        "status": "cold",
                        "color": "#4466ff",
                        "custom_type": 1005,
                        "team_id": "4755811",
                        "deleted": false,
                        "url": "https://app.clickup.com/t/86883jmad",
                        "access": true
                    }
                ],
                "required": false
            },
            {
                "id": "8c913745-16df-424e-99a8-22e217545286",
                "name": "CRM-Proposals",
                "type": "list_relationship",
                "type_config": {
                    "fields": [
                        {
                            "name": "CRM-Company",
                            "field": "cf_57d1e2a8-bf1e-4698-a901-4ed5674c9efb",
                            "width": 100,
                            "hidden": false
                        }
                    ],
                    "subcategory_id": "901103239770",
                    "linked_subcategory_access": true,
                    "subcategory_inverted_name": "CRM-Proposals"
                },
                "date_created": "2024-04-08T03:10:38.113Z",
                "hide_from_guests": false,
                "required": false
            },
            {
                "id": "f5029db2-8460-48a1-a36d-2703f1a04576",
                "name": "CRM-Interactions",
                "type": "list_relationship",
                "type_config": {
                    "fields": [],
                    "subcategory_id": "901103867045",
                    "linked_subcategory_access": true,
                    "subcategory_inverted_name": "CRM-Interactions"
                },
                "date_created": "2024-07-22T15:00:55.142Z",
                "hide_from_guests": false,
                "required": false
            }
        ],
        "__IMTLENGTH__": 4,
        "__IMTINDEX__": 2
    },
    {
        "id": "86883f6bm",
        "custom_id": null,
        "custom_item_id": 1001,
        "name": "Joe Montana",
        "text_content": "",
        "description": "",
        "status": {
            "status": "Open",
            "id": "p90110131594_BQHW4Q7x",
            "color": "#87909e",
            "type": "open",
            "orderindex": 0
        },
        "orderindex": "119418052.00000000000000000000000000000000",
        "date_created": "2024-04-04T02:26:16.354Z",
        "date_updated": "2024-08-14T04:55:22.163Z",
        "date_closed": null,
        "date_done": null,
        "archived": false,
        "creator": {
            "id": 6357496,
            "username": "Robert Curley",
            "color": "#757380",
            "email": "rcurley@insigniaenv.com",
            "profilePicture": null
        },
        "assignees": [],
        "group_assignees": [],
        "watchers": [
            {
                "id": 6357496,
                "username": "Robert Curley",
                "color": "#757380",
                "initials": "RC",
                "email": "rcurley@insigniaenv.com",
                "profilePicture": null
            },
            {
                "id": 30047465,
                "username": "ClickUp Admin",
                "color": "#595d66",
                "initials": "CA",
                "email": "twp@insigniaenv.com",
                "profilePicture": null
            }
        ],
        "checklists": [],
        "tags": [],
        "parent": null,
        "priority": null,
        "due_date": null,
        "start_date": null,
        "points": null,
        "time_estimate": 0,
        "custom_fields": {
            "CRM-Company": [
                {
                    "id": "8685rg4qc",
                    "name": "San Francisco 49ers",
                    "status": "target",
                    "color": "#e16b16",
                    "custom_type": 1002,
                    "team_id": "4755811",
                    "deleted": false,
                    "url": "https://app.clickup.com/t/8685rg4qc",
                    "access": true
                }
            ],
            "CRM-Company Acronym": "49ers",
            "CRM-Company Type": "Client",
            "CRM-Address": {
                "location": {
                    "lat": 37.7135483,
                    "lng": -122.3857003
                },
                "place_id": "ChIJNRtd3jB_j4ARj0uyMgc9oSk",
                "formatted_address": "602 Jamestown Ave, San Francisco, CA 94124, USA"
            },
            "CRM-Phone": "+1 415 555 4949",
            "CRM-Email": "Joe.Montana@49ers.com",
            "CRM-Title": "Champ",
            "CRM-Projects": [
                {
                    "id": "86883fdw0",
                    "name": "Superbowl 58",
                    "status": "active",
                    "color": "#008844",
                    "custom_type": 1004,
                    "team_id": "4755811",
                    "deleted": false,
                    "url": "https://app.clickup.com/t/86883fdw0",
                    "access": true
                }
            ],
            "CRM-Opportunities": [
                {
                    "id": "86883fe00",
                    "name": "Superbowl 59",
                    "status": "hot",
                    "color": "#d33d44",
                    "custom_type": 1005,
                    "team_id": "4755811",
                    "deleted": false,
                    "url": "https://app.clickup.com/t/86883fe00",
                    "access": true
                }
            ],
            "CRM-Proposals": [
                {
                    "id": "8688478df",
                    "name": "My Big Proposal",
                    "status": "Open",
                    "color": "#87909e",
                    "custom_type": 1007,
                    "team_id": "4755811",
                    "deleted": false,
                    "url": "https://app.clickup.com/t/8688478df",
                    "access": true
                }
            ]
        },
        "dependencies": [],
        "linked_tasks": [],
        "locations": [],
        "team_id": "4755811",
        "url": "https://app.clickup.com/t/86883f6bm",
        "sharing": {
            "public": false,
            "public_share_expires_on": null,
            "public_fields": [
                "assignees",
                "priority",
                "due_date",
                "content",
                "comments",
                "attachments",
                "customFields",
                "subtasks",
                "tags",
                "checklists",
                "coverimage"
            ],
            "token": null,
            "seo_optimized": false
        },
        "permission_level": "create",
        "list": {
            "id": "901100952151",
            "name": "CRM-Contacts",
            "access": true
        },
        "project": {
            "id": "90110442401",
            "name": "hidden",
            "hidden": true,
            "access": true
        },
        "folder": {
            "id": "90110442401",
            "name": "hidden",
            "hidden": true,
            "access": true
        },
        "space": {
            "id": "90110131594"
        }, ...Original custom fields data removed here...
        
        "__IMTLENGTH__": 4,
        "__IMTINDEX__": 4
    }
]

And the output post filter, which is properly reducing that to just one matching result:

[
    {
        "array": [
            {
                "id": "86883jhgz",
                "name": "Steph Curry",
                "status": {
                    "status": "Open",
                    "id": "p90110131594_BQHW4Q7x",
                    "color": "#87909e",
                    "type": "open",
                    "orderindex": 0
                },
                "__IMTINDEX__": 2,
                "__IMTLENGTH__": 4,
                "custom_fields": {
                    "CRM-Company": [
                        {
                            "id": "86883fdb4",
                            "name": "Golden State Warriors",
                            "status": "target",
                            "color": "#e16b16",
                            "custom_type": 1002,
                            "team_id": "4755811",
                            "deleted": false,
                            "url": "https://app.clickup.com/t/86883fdb4",
                            "access": true
                        }
                    ],
                    "CRM-Address": {
                        "location": {
                            "lat": 37.7680183,
                            "lng": -122.3878772
                        },
                        "place_id": "ChIJvTaOg8Z_j4ARCdO8LroPfBA",
                        "formatted_address": "1 Warriors Way, San Francisco, CA 94158, USA"
                    },
                    "CRM-Phone": "+1 415 555 4545",
                    "CRM-Email": "scurry@warriors.com",
                    "CRM-Title": "Champ",
                    "CRM-Projects": [
                        {
                            "id": "8689b13hj",
                            "name": "2025 NBA Finals",
                            "status": "Open",
                            "color": "#87909e",
                            "custom_type": 1004,
                            "team_id": "4755811",
                            "deleted": false,
                            "url": "https://app.clickup.com/t/8689b13hj",
                            "access": true
                        },
                        {
                            "id": "86883jggg",
                            "name": "Chase Center Upgrade Project",
                            "status": "delayed",
                            "color": "#f8ae00",
                            "custom_type": 1004,
                            "team_id": "4755811",
                            "deleted": false,
                            "url": "https://app.clickup.com/t/86883jggg",
                            "access": true
                        }
                    ],
                    "CRM-Opportunities": [
                        {
                            "id": "86883jmad",
                            "name": "Stanley Cup 2040",
                            "status": "cold",
                            "color": "#4466ff",
                            "custom_type": 1005,
                            "team_id": "4755811",
                            "deleted": false,
                            "url": "https://app.clickup.com/t/86883jmad",
                            "access": true
                        }
                    ]
                }
            }
        ],
        "__IMTAGGLENGTH__": 1
    }
]

I think I did this correctly with your suggestions, but would be open to any other ideas.

blueprint.json (140.0 KB)

You might not need an aggregator-iterator, since you already want to edit each individual task that passes the filter.

Hope this helps! Let me know if there are any further questions or issues.

@samliew


P.S.: Did you know, the concepts of about 70% of questions asked on this forum are already covered in the Make Academy. Investing some effort into it will save you lots of time and frustration using Make later!