Trouble retrieving value from collection

I’m a new user, so take it easy on me! I am trying to extract specific values from the “Form Data” (collection), but for some reason it doesn’t show it as a clickable option in the mapping tool (see screenshots).

I have tried using the get() function as well as dot notation, but I can’t seem to figure out the proper syntax. Do keys with spaces need to have underscores?

It’s a “collection” and not an “array”. The iterator does not seem to work on collections.

{{1.data.form_data.Enter your word trademark (or any words contained within your logo)}}

Not sure if the spaces in the key name are causing an issue.

Any help is appreciated!


Welcome to the Make community!

Please provide the output bundles of the modules from the scenario History tab, then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.
Screenshot_2023-10-06_141025

A.

Save each bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading them here will look like this:

module-1-output-bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

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.

This will allow others to better assist you. Thanks!

2 Likes

Hi there, thanks for your reply.

It seems that I am not able to upload txt files to the forum. I have pasted the output file below.

[
    {
        "data": {
            "id": "ECA4D97C",
            "date_added": "2024-04-05T05:02:31.000Z",
            "date_updated": "2024-04-05T05:02:31.000Z",
            "date_started": "2024-04-05T05:02:31.000Z",
            "date_completed": null,
            "date_due": null,
            "client": {
                "id": 8,
                "aff_id": null,
                "date_added": "2022-08-20T17:21:39.000Z",
                "name_f": "Shelly",
                "name_l": "Miranda",
                "email": "testemail@gmail.com",
                "company": null,
                "tax_id": null,
                "phone": null,
                "note": null,
                "balance": null,
                "optin": "Yes",
                "stripe_id": null,
                "custom_fields": [],
                "status": 3,
                "role_id": null,
                "name": "Shelly Miranda",
                "employee_id": null,
                "managers": [],
                "spent": "0.00",
                "ga_cid": null,
                "team_owner_ids": [],
                "team_member_ids": []
            },
            "tags": [],
            "status": "Submitted",
            "price": "0.00",
            "quantity": 1,
            "invoice_id": "ECA4D97C",
            "service": "Trademark Assessment",
            "service_id": 14,
            "user_id": 8,
            "employees": [],
            "note": null,
            "form_data": {
                "Trademark Type": "Word mark, name or slogan in plain text",
                "Enter your word trademark (or any words contained within your logo)": "test",
                "Select your desired trademark countries": "Canada, United Kingdom, United States",
                "What goods and/or services do you intend to sell?": "test goods",
                "Date of first-use": "Apr 4, 2024",
                "Anything else we should know?": "test",
                "How did you hear about us?": "Twitter"
            },
            "paysys": "Account Balance",
            "currency": "USD",
            "subscription": null,
            "options": [],
            "invoice": {
                "id": "ECA4D97C",
                "number": "5900",
                "client": {
                    "id": 8,
                    "aff_id": null,
                    "date_added": "2022-08-20T17:21:39+00:00",
                    "name_f": "Shelly",
                    "name_l": "Miranda",
                    "email": "testemail@gmail.com",
                    "company": null,
                    "tax_id": null,
                    "phone": null,
                    "note": null,
                    "balance": null,
                    "optin": "Yes",
                    "stripe_id": null,
                    "custom_fields": [],
                    "status": 3,
                    "role_id": null,
                    "name": "Shelly Miranda",
                    "employee_id": null,
                    "managers": [],
                    "ga_cid": null,
                    "team_owner_ids": [],
                    "team_member_ids": []
                },
                "items": [
                    {
                        "amount": "0.00",
                        "created_at": "2024-04-05T05:02:30.000000Z",
                        "description": null,
                        "discount": "0.00",
                        "discount2": null,
                        "id": 1272,
                        "invoice_id": "ECA4D97C",
                        "name": "Trademark Assessment",
                        "options": [],
                        "order_id": "ECA4D97C",
                        "quantity": 1,
                        "service_id": 14,
                        "total": 0,
                        "updated_at": "2024-04-05T05:02:31.000000Z"
                    }
                ],
                "billing_address": {
                    "line_1": null,
                    "line_2": null,
                    "city": null,
                    "country": null,
                    "state": null,
                    "postcode": null,
                    "name_f": "Shelly",
                    "name_l": "Miranda",
                    "tax_id": null,
                    "company_name": null,
                    "company_vat": null
                },
                "status": "Paid",
                "created_at": "2024-04-05T05:02:30+00:00",
                "date_due": "2024-04-05T05:02:30+00:00",
                "date_paid": "2024-04-05T05:02:31+00:00",
                "credit": null,
                "tax": "0.00",
                "tax_name": "GST",
                "tax_percent": "5.000",
                "currency": "USD",
                "reason": "assessment",
                "note": "",
                "ip_address": "2604:3d09:4979:5c10:33:6e4a:58a2:c11f",
                "loc_confirm": null,
                "recurring": null,
                "coupon_id": null,
                "transaction_id": null,
                "paysys": "Account Balance",
                "subtotal": "0.00",
                "total": "0.00",
                "employee_id": null,
                "view_link": "https://site.spp.io/invoices/ECA4D97C?key=69749fb9ee69237c3a7ab055e751131e",
                "download_link": "https://site.spp.io/invoices/ECA4D97C/download?key=69749fb9ee69237c3a7ab055e751131e",
                "subscription": null
            },
            "order_service": {
                "id": 14,
                "name": "Trademark Assessment",
                "description": null,
                "image": null,
                "recurring": 0,
                "price": "0.00",
                "pretty_price": "$0.00",
                "currency": "USD",
                "f_price": null,
                "f_period_l": null,
                "f_period_t": null,
                "r_price": null,
                "r_period_l": null,
                "r_period_t": null,
                "recurring_action": null,
                "multi_order": null,
                "request_orders": null,
                "option_categories": null,
                "option_variants": null,
                "deadline": null,
                "public": 1,
                "sort_order": null,
                "braintree_plan_id": null,
                "group_quantities": null,
                "addon_to": null,
                "folder_id": null,
                "metadata": [],
                "hoth_product_key": null,
                "hoth_package_name": null,
                "created_at": "2022-07-26T04:17:04.000000Z",
                "updated_at": "2024-03-10T20:43:47.000000Z",
                "provider_id": null,
                "provider_service_id": null,
                "deleted_at": null,
                "metadata_delete": null,
                "media": []
            },
            "addons": [],
            "ratings": [],
            "metadata": [],
            "messages": []
        },
        "created": "2024-04-05T05:02:32.000Z",
        "event": "order.created",
        "token": "66hGZnnImoN05tpGFkpnIjG6x2kNLTlm"
    }
]

Hi @Zachp

When we tried the output you provided, it worked fine. You can hardcode the following where you want to map data:
{{1.data.form_data.Enter your word trademark (or any words contained within your logo)}}

If this is still not working, then try change the collection to array and then map the required value.

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

If I paste the output bundle into a json parser for testing, it seems to recognize the collection values in the next module. But when it is coming directly from my trigger module, it doesn’t allow me to select the values within the collection in the next module. (see the OP screenshots)

How do I “change the collection to an array and then map the required value”?

When I try to call the value explicitly using

{{1.data.form_data.Enter your word trademark (or any words contained within your logo)}}

It gives me error:

Invalid reference ‘data.form_data’.

Screenshot 2024-04-05 004420

@Zachp
I created a json structure for form data as a collection :

Then converted it into an array:
image

You can use the toArray function from here:
image

mapped the array to get the value :

output:
image

2 Likes

@Msquare_Automation Thanks for your efforts, but it is giving me an error when trying to use the function toArray. It shows the type as “text” when I hover instead of “collection”, very odd.

The operation failed with an error. Failed to map 'value': Function 'toArray' finished with error! '{empty}' is not a valid collection

Sometimes this happens that the collection is not being pulled properly.
Usually that’s the case when the collection keys are fully dynamic.

As you know the key name, you can map it “manually”.

As keys don’t allow spaces in it, you need to wrap your key name in `…` quotes.

Try to use this instead:

{{1.data.form_data.`Enter your word trademark (or any words contained within your logo)`}}
4 Likes

Thank you!! @Manuel.Techflow.ai

I was pulling my hair out with this. You nailed it!

3 Likes