Dynamically Adding to an Array

Hi Everyone,

I’m about one scenario execution from throwing my computer out the window haha

I am trying to join together multiple outputs into JSON to then send in an API response. The outputs are coming from a series of data from different tables in the db being joined together. The number of outputs changes on each execution.

For the life of me I cannot get the operations into an array to then progress from there into a string, JSON etc.

I’ve tried several different ways. Making Variables, trying to add to an array created at the beginning of the scenario, array aggregators.

I have looked at as many articles and videos that I can find and I think there may be some issue with doing it dynamically… Maybe? That’s the best answer I can find.

Can someone please share their thoughts?

Any help would be appreciated. Thanks in advance.
Tim

Output Bundle:
[
{
“Contact + Messages”: “{\n "contact_id": "238",\n "first_name": "Kelvin",\n "last_name": "Alphonso",\n "title": "Design Engineer",\n "messages": [\n {\n "id": "45",\n "sent": "false",\n "type": "email",\n "content": "Hi Kelvin,\n\nI noticed your role as a Design Engineer at ResMed and the innovative work you’re doing in sleep and respiratory care devices. Informatica’s data management solutions could significantly enhance your design process and product development.\n\nOur customers in the medical device industry have overcome challenges such as:\n\n- Data Integration: Streamlining access to disparate data sources for faster, more informed design decisions.\n- Regulatory Compliance: Ensuring data accuracy and traceability to meet strict industry standards.\n- Cross-functional Collaboration: Improving data sharing between design, manufacturing, and quality assurance teams.\n\nWould you be open to a quick 30-minute chat about how we’ve helped similar engineers boost their efficiency and innovation?\n\nCheers,\nTim from Informatica Australia",\n "subject": "Revolutionise Your Design Process Today",\n "approved": "false"\n },\n {\n "id": "46",\n "sent": "false",\n "type": "linkedin",\n "content": "Hi Kelvin, I noticed your role as a Design Engineer at ResMed. As someone from Informatica, I’m keen to discuss how our cloud data management solutions could streamline your design process and boost innovation in sleep apnoea devices. Fancy a chat about leveraging data for groundbreaking medical tech?",\n "subject": "-",\n "approved": "false"\n },\n {\n "id": "47",\n "sent": "false",\n "type": "email",\n "content": "Hi Kelvin,\n\nI hope my previous email about revolutionising your design process piqued your interest.\n\nAfter researching ResMed’s innovative work in sleep and respiratory care, I’ve identified some challenges you might be facing as a Design Engineer:\n\n- Data Integration: Unifying information from various sources for faster, data-driven design decisions.\n- Cross-functional Collaboration: Improving data sharing between design, manufacturing, and quality assurance teams.\n- Regulatory Compliance: Ensuring data accuracy and traceability to meet strict industry standards.\n\nAre these aligned with your current priorities, or is there something else on your mind?\n\nMany of our medical device clients have overcome similar hurdles using Informatica’s solutions. Would you be open to a brief 15-minute call to discuss how we’ve helped engineers like you boost efficiency and drive innovation?",\n "subject": "Unlock Your Design’s Hidden Potential",\n "approved": "false"\n },\n {\n "id": "48",\n "sent": "false",\n "type": "email",\n "content": "Hi Kelvin,\n\nI hope my previous emails about enhancing your design process caught your attention. After researching ResMed’s innovative work in sleep and respiratory care, I’ve identified some challenges you might be facing as a Design Engineer:\n\n- Data integration across multiple systems and departments\n- Streamlining collaboration with product development and manufacturing teams\n- Ensuring regulatory compliance while maintaining design flexibility\n- Leveraging data insights for continuous product innovation\n\nAre these aligned with your current priorities, or is there something else on your mind?\n\nMany of our medical device clients have overcome similar hurdles using Informatica’s solutions. For instance, one company reduced their design cycle time by 30% and improved regulatory compliance by 40%.\n\nWould you be open to a brief 30-minute call to discuss how we’ve helped engineers like you boost efficiency and drive innovation?",\n "subject": "Overcome Your Hidden Design Roadblocks",\n "approved": "false"\n }\n ]\n }”
}
]

Welcome to the Make community!

Looks like your source module of the aggregator is incorrect.

Setting the Correct Aggregator Source

You need to set the “Source Module” field of the aggregator to where the bundles are coming from. This is usually an Iterator module, but can also be a search/list/repeater module.

For more information, please refer to the Make Academy.

Combining Bundles Using Aggregators

Every result (item/record) from trigger/iterator/list/search/match modules will output a bundle. This can result in multiple bundles, which then trigger multiple operations in future modules (one operation per bundle). To “combine” multiple bundles into a single variable, you’ll need to use an aggregator of some sort.

Aggregators are modules that accumulate multiple bundles into one single bundle. An example of a commonly-used aggregator module is the Array aggregator module. The next popular aggregator is the Text Aggregator which is very flexible and can apply to many use-cases like building of JSON, CSV, HTML.

You can find out more about the other types of aggregator modules here:

Mapping a Specific Structure Into a Complex Field

The Array Aggregator module is very powerful because it allows you to build a complex array of collections for a later module’s field to map multiple items (collections) to it.

This is done using the “Target structure type” field in an Array Aggregator module.

Here is an example:

As you can see, the “Map” toggle on complex fields are used when you have an array. You can easily build an array variable to map to a future module’s field, by using an Array Aggregator module and select the “Target Structure Type” as the future module’s field you have mapped the array into.

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

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

1 Like

Cannot thank you enough @samliew

You saved me 17 grey hairs and my partners hearing haha

2 Likes