Map function giving empty array

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.




blueprint.json (16.8 KB)

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
(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

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!

2 Likes

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

image

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
Visit us here
Youtube Channel

2 Likes

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.

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
Visit us here
Youtube Channel

1 Like

Hi @Msquare_Automation,

HTTP output bundle below…

Thanks for your help.

[
    {
        "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
    }
]

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)

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

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.

2 Likes

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

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

Screenshot_2023-11-16_091120

2 Likes

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
2 Create a json structure with value and type.


3.Use aggregator to aggregate.
image
Output:

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
Visit us here
Youtube Channel

2 Likes

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.

Hi @samliew,

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

Thanks for your help.

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
Visit us here
Youtube Channel

2 Likes

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

1. Use “Set Variable” module with built-in function toCollection()

Screenshot_2023-11-20_121110

Output:

Screenshot_2023-11-20_121143

3 Likes

Easy when you know how.

Thanks thats just what I was after.

2 Likes