# Map function giving empty array

**URL:** <https://community.make.com/t/map-function-giving-empty-array/19284>\
**Category:** Questions\
**Tags:** functions\
**Created:** [November 8, 2023, 8:57pm UTC](https://community.make.com/t/map-function-giving-empty-array/19284 "2023-11-08T20:57:55Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alan\_Heat](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@Alan\_Heat](https://community.make.com/u/Alan_Heat)\
**Post date:** [November 8, 2023, 8:57pm UTC](https://community.make.com/t/map-function-giving-empty-array/19284/1 "2023-11-08T20:57:55Z")

</div>

Hi,

Im struggling to get the map function to work in my use case and would really appreciate some help.

Basically no matter what I try I just get an empty array result. Im sure the Raw names are correct but can’t work out whats wrong.

Thanks in advance for any help.

 ![Screenshot 2023-11-08 at 20.48.57](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/3/f/3fe6c7555aeecc2a291054acb355b7fa32e2ac96.png)  
 ![Screenshot 2023-11-08 at 20.53.42](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/6/c/6c757d32b370cc3fa92721bf50751aea7749d1cd.jpeg)  
 ![Screenshot 2023-11-08 at 20.54.03](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/c/3/c3b2bca5ea00a1c7acd6a481b88064c7d57ebf1a.jpeg)  
[blueprint.json](https://community.make.com/uploads/short-url/1YxLKOj4A039q8wAt3Pkz7HgpuM.json) (16.8 KB)

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [November 9, 2023, 1:43am UTC](https://community.make.com/t/map-function-giving-empty-array/19284/2 "2023-11-09T01:43:16Z")

</div>

Welcome to the Make community!

## 1. Scenario blueprint

Please export the scenario blueprint file to allow others to view the mappings and settings. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

 ![Screenshot_2023-08-24_230826](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/2/2ff55ee04419049c127f183db2b3eebfbbbbfc64.png)  
(Note: Exporting your scenario will not include private information or keys to your connections)

Uploading it here will look like this:

> blueprint.json (12.3 KB)

## 2. And most importantly, Output bundles

Please provide the **output bundles** of modules [5] by running the scenario, then click the white speech bubble on the top-right of each module, save the contents as a text file, and upload it here into this discussion thread:

 ![Screenshot_2023-10-06_141025](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/2/8/2876156ab3ea5bc9e40bbc0edfb9f025406b7c48.png)

Providing the 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!

---

<div class="post-metadata">

**Author:** ![Msquare\_Automation](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/msquare_automation/32/6634_2.png) [@Msquare\_Automation](https://community.make.com/u/Msquare_Automation)\
**Post date:** [November 9, 2023, 3:45am UTC](https://community.make.com/t/map-function-giving-empty-array/19284/3 "2023-11-09T03:45:52Z")

</div>

Hi @Alan_Heat

I could see that inside the map function you’ve included customfields which is a array with collection. Value, name all these fields are with in the collection inside the array. This we couldn’t get using map.

To solve your issue, please follow the below steps.  
1.use iterator to iterate the CustomFields array  
2. Use filter to pass the collections having name Unit type.  
3. Use text aggregator to aggregate the value.  
4. If you want array form please use split function.  
eg:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/3/1/312a5d4ea15f4d38c94c60a6bfa4f59afb45ed38.png)

![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/8/2/82889df454a66dc5c4980a0ea0563b1ced073f8c.png)

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/c/7/c7421935dfb26297cc2bb0947c4dfc26501156ab.png)

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/4/2/4271a292b4ebaf15980fd82b64b429e949c4b4b1.png)

If you require additional assistance, please don’t hesitate to reach out to us.  
[MSquare Support](https://calendly.com/msquarepro/meeting)  
Visit us [here](https://www.msquare.pro/)  
[Youtube Channel](https://www.youtube.com/channel/UCqidlIIwbejxZmRUWBICcjQ)

---

<div class="post-metadata">

**Author:** ![Alan\_Heat](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@Alan\_Heat](https://community.make.com/u/Alan_Heat)\
**Post date:** [November 9, 2023, 4:34pm UTC](https://community.make.com/t/map-function-giving-empty-array/19284/4 "2023-11-09T16:34:45Z")

</div>

Hi @Msquare_Automation,

Thanks very much for your reply.

I have now uploaded the Blueprint to better assist I hope.

I tried your suggestion and it works for one item but I was hoping to get the Type and Value from all collections within the array that way I will be able to map them better later in my senario.

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Msquare\_Automation](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/msquare_automation/32/6634_2.png) [@Msquare\_Automation](https://community.make.com/u/Msquare_Automation)\
**Post date:** [November 11, 2023, 3:29am UTC](https://community.make.com/t/map-function-giving-empty-array/19284/5 "2023-11-11T03:29:22Z")

</div>

Hi @Alan_Heat

You’ve uploaded a scenario blueprint that requires a connection, making it challenging to analyze further. To proceed, could you provide an HTTP output bundle?

If you require additional assistance, please don’t hesitate to reach out to us.  
[MSquare Support](https://calendly.com/msquarepro/meeting)  
Visit us [here](https://www.msquare.pro/)  
[Youtube Channel](https://www.youtube.com/channel/UCqidlIIwbejxZmRUWBICcjQ)

---

<div class="post-metadata">

**Author:** ![Alan\_Heat](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@Alan\_Heat](https://community.make.com/u/Alan_Heat)\
**Post date:** [November 14, 2023, 7:57pm UTC](https://community.make.com/t/map-function-giving-empty-array/19284/6 "2023-11-14T19:57:21Z")

</div>

Hi @Msquare_Automation,

HTTP output bundle below…

Thanks for your help.

```auto
[
    {
        "statusCode": 200,
        "headers": [
            {
                "name": "date",
                "value": "Wed, 15 Nov 2023 15:58:47 GMT"
            },
            {
                "name": "content-type",
                "value": "application/json;charset=utf-8"
            },
            {
                "name": "content-length",
                "value": "487"
            },
            {
                "name": "connection",
                "value": "close"
            },
            {
                "name": "report-to",
                "value": "{\"group\":\"csp-endpoint\",\"max_age\":10886400,\"endpoints\":[{\"url\":\"https://heatdifferent.simprosuite.com/tools/csp-report/cspReport.php\"}],\"include_subdomains\":true}"
            },
            {
                "name": "content-security-policy-report-only",
                "value": "default-src 'self' 'unsafe-inline' data: wss: blob: *.intuit.com *.github.io *.raygun.io *.plaid.com *.squareupsandbox.com *.squareup.com *.squarecdn.com *.walkme.com *.googleapis.com *.google.com *.googletagmanager.com *.simprogroup.com *.simprocloud.net *.simprocloud.com *.locationiq.com https://data.resources.simprogroup.com *.google-analytics.com https://lookup.simprocloud.com *.simprosuite.com; img-src * data: blob: cid: file:; font-src * data:; frame-src *; script-src 'self' 'unsafe-eval' 'unsafe-inline' *.intuit.com *.github.io *.raygun.io *.plaid.com *.squareupsandbox.com *.squareup.com *.squarecdn.com *.walkme.com *.simprogroup.com *.simprocloud.net *.simprocloud.com *.google.com *.googletagmanager.com *.cloudfront.net *.cloudflare.com https://data.resources.simprogroup.com *.pendo.io *.google-analytics.com *.simprosuite.com; report-uri /tools/csp-report/cspReport.php; report-to csp-endpoint"
            },
            {
                "name": "access-control-allow-headers",
                "value": "*"
            },
            {
                "name": "resource-base-uri",
                "value": "/api/v1.0/companies/0/customerAssets/"
            },
            {
                "name": "resource-id",
                "value": "1470"
            },
            {
                "name": "x-response-time",
                "value": "412.104ms"
            },
            {
                "name": "content-encoding",
                "value": "gzip"
            },
            {
                "name": "vary",
                "value": "Accept-Encoding"
            },
            {
                "name": "server",
                "value": "lighttpd"
            }
        ],
        "cookieHeaders": [],
        "data": {
            "ID": 1470,
            "AssetType": {
                "ID": 55,
                "Name": "1.0 - ASHP 1 phase"
            },
            "DisplayOrder": 1,
            "CustomerContract": null,
            "StartDate": "2023-07-19",
            "LastTest": {
                "Result": "No Test",
                "Date": null,
                "ServiceLevel": null
            },
            "Archived": false,
            "CustomFields": [
                {
                    "CustomField": {
                        "ID": 549,
                        "Name": "Serial no. (indoor unit)",
                        "Type": "Barcode",
                        "ListItems": null
                    },
                    "Value": "7727502301427122"
                },
                {
                    "CustomField": {
                        "ID": 456,
                        "Name": "Make",
                        "Type": "Text",
                        "ListItems": null
                    },
                    "Value": "Viessmann"
                },
                {
                    "CustomField": {
                        "ID": 458,
                        "Name": "Model",
                        "Type": "Text",
                        "ListItems": null
                    },
                    "Value": "Vitocal 200-A AWO-M-E-AC 201.A16"
                },
                {
                    "CustomField": {
                        "ID": 561,
                        "Name": "Serial no. (outdoor unit)",
                        "Type": "Barcode",
                        "ListItems": null
                    },
                    "Value": "7727688201234128"
                },
                {
                    "CustomField": {
                        "ID": 461,
                        "Name": "A7 W35 Output (kW)",
                        "Type": "Text",
                        "ListItems": null
                    },
                    "Value": "8.64"
                },
                {
                    "CustomField": {
                        "ID": 462,
                        "Name": "Unit type",
                        "Type": "List",
                        "ListItems": [
                            "Master",
                            "Slave"
                        ]
                    },
                    "Value": "Master"
                }
            ],
            "ParentID": null,
            "DateModified": "2023-07-19T15:45:18+01:00",
            "IoTAssetID": null,
            "Site": {
                "ID": 1293,
                "Name": "Southwood Hall Southwood Norwich Norfolk NR13 3LR"
            }
        },
        "fileSize": 1042
    }
]

```

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [November 15, 2023, 1:16am UTC](https://community.make.com/t/map-function-giving-empty-array/19284/7 "2023-11-15T01:16:36Z")

</div>

Sorry, we can’t use that as it isn’t valid JSON. In future, could you format JSON code before submitting the reply, otherwise the forum software will convert some characters to make them invalid (checked when pasted into [https://jsonformatter.org](https://jsonformatter.org))

## 1.

Could you format your JSON by editing three backticks ````` before and after the code, like this:

> ```  
> _input/output bundle goes here_  
> ```

## 2.

or use the format code button in the editor:  
 ![Screenshot_2023-10-02_191027](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/b/4/b485b6572c7a1c438f9b191c54e63d351008304c.png)

## 3.

Alternatively, you can paste and save the contents of the bundles in your text editor as a `bundle.json` file, and upload it here into this discussion thread.

Once the post has been submitted, it’s too late to format it since it’s already butchered, and you need to make a fresh copy of output bundle, and format it before submitting the forum post.

---

<div class="post-metadata">

**Author:** ![Alan\_Heat](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@Alan\_Heat](https://community.make.com/u/Alan_Heat)\
**Post date:** [November 15, 2023, 4:02pm UTC](https://community.make.com/t/map-function-giving-empty-array/19284/8 "2023-11-15T16:02:58Z")

</div>

Thanks for the tip i’ve edited the previous reply.

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [November 15, 2023, 4:03pm UTC](https://community.make.com/t/map-function-giving-empty-array/19284/9 "2023-11-15T16:03:46Z")

</div>

I got this output from your scenario blueprint and output bundle. What about this you are having issues with?

![Screenshot_2023-11-16_091120](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/d/d/dda4d2292c99d05852d3c00a716c6c5f22d5fdc9.png)

---

<div class="post-metadata">

**Author:** ![Msquare\_Automation](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/msquare_automation/32/6634_2.png) [@Msquare\_Automation](https://community.make.com/u/Msquare_Automation)\
**Post date:** [November 16, 2023, 3:50am UTC](https://community.make.com/t/map-function-giving-empty-array/19284/10 "2023-11-16T03:50:02Z")

</div>

Hi @Alan_Heat

I hope you need a array of type and value from the CustomFields array. Please follow the below steps.

1.Use iterator to iterate the array.  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/1/0/1069e9617f9d737fc70347725ee4680d7b1eb13d.png)  
2 Create a json structure with value and type.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/2/d/2d7a3cf62c5f9503ec661dc60759af59c59fd0a0.png)  
3.Use aggregator to aggregate.  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/5/5/5528d627ac078511e6e9f5555a9d021c89d76240.png)  
Output:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/1/0/102b48f18d506274f33741e7e36f2bf69202010d.png)

If you require additional assistance, please don’t hesitate to reach out to us.  
[MSquare Support](https://calendly.com/msquarepro/meeting)  
Visit us [here](https://www.msquare.pro/)  
[Youtube Channel](https://www.youtube.com/channel/UCqidlIIwbejxZmRUWBICcjQ)

---

<div class="post-metadata">

**Author:** ![Alan\_Heat](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@Alan\_Heat](https://community.make.com/u/Alan_Heat)\
**Post date:** [November 19, 2023, 9:06pm UTC](https://community.make.com/t/map-function-giving-empty-array/19284/11 "2023-11-19T21:06:06Z")

</div>

Hi @Msquare_Automation

Thanks for this.

Im looking to return the Name and Value.

Ive tried what you have shown but am not sure if I am setting up the create JSON module properly could you show in more detail holw to do this?

Also when the create JSON module is set up it doesn’t show in the array aggregator target structure type as shown in your example.

But it looks like this will work once I understand how to set it up properly.

---

<div class="post-metadata">

**Author:** ![Alan\_Heat](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@Alan\_Heat](https://community.make.com/u/Alan_Heat)\
**Post date:** [November 19, 2023, 9:07pm UTC](https://community.make.com/t/map-function-giving-empty-array/19284/12 "2023-11-19T21:07:38Z")

</div>

Hi @samliew,

Im looking to return the Name and associated Value from the collection.

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Msquare\_Automation](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/msquare_automation/32/6634_2.png) [@Msquare\_Automation](https://community.make.com/u/Msquare_Automation)\
**Post date:** [November 20, 2023, 3:32am UTC](https://community.make.com/t/map-function-giving-empty-array/19284/13 "2023-11-20T03:32:09Z")

</div>

Hi @Alan_Heat

To solve your issue, please check the loom below.

If you require additional assistance, please don’t hesitate to reach out to us.  
[MSquare Support](https://calendly.com/msquarepro/meeting)  
Visit us [here](https://www.msquare.pro/)  
[Youtube Channel](https://www.youtube.com/channel/UCqidlIIwbejxZmRUWBICcjQ)

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [November 20, 2023, 4:12am UTC](https://community.make.com/t/map-function-giving-empty-array/19284/14 "2023-11-20T04:12:53Z")

</div>

> [@Alan\_Heat](#):
>
> Im looking to return the Name and associated Value from the collection.

That’s easy. You’ll only need a single module after your HTTP module.

## 1. Use “Set Variable” module with built-in function [`toCollection()`](https://www.make.com/en/help/functions/array-functions#tocollection--array--key--value-)

 ![Screenshot_2023-11-20_121110](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/f/8/f8974cf734f2f4651f2a40b7fd59650645fabb76.png)

### Output:

 ![Screenshot_2023-11-20_121143](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/2/e/2ee7eaf5cecc43c4c2baf920d08ff2e3a081a8e0.png)

---

<div class="post-metadata">

**Author:** ![Alan\_Heat](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@Alan\_Heat](https://community.make.com/u/Alan_Heat)\
**Post date:** [November 22, 2023, 10:19pm UTC](https://community.make.com/t/map-function-giving-empty-array/19284/15 "2023-11-22T22:19:32Z")

</div>

Easy when you know how.

Thanks thats just what I was after.

---

<div class="post-metadata">

**Author:** ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)\
**Post date:** [December 6, 2023, 11:07pm UTC](https://community.make.com/t/map-function-giving-empty-array/19284/16 "2023-12-06T23:07:16Z")

</div>

This topic was automatically closed because it's resolved or inactive. Please, start a new topic.


