Make Custom Apps - How to iterate

Hi there everyone,
I’ve been working my way through creating a custom app with a handful of modules. All going well so far but I’ve hit something I can’t solve.

How to correctly iterate on the response

"response": {
	"iterate": {
		"container": "{{body.transitions.fields)}}"
	},
	"output": {
		"label": "{{item.name}}",
		"name": "{{item.name}}",
		"value": "{{item.fieldId}}"
	}
}

If response

{
    "transitions": [
        {
            "id": "11",
            "name": "Terminated",
            "opsbarSequence": 20,
            "fields": {
                "customfield_15309": {
                    "required": false,
                    "name": "Financial date of termination",
                    "fieldId": "customfield_15309",
                },
                "customfield_14824": {
                    "required": false,
                    "name": "Date of last working day",
                    "fieldId": "customfield_14824",
                },
                "customfield_14892": {
                    "required": false,
                    "name": "Redirect only new emails to",
                    "fieldId": "customfield_14892",
                },
                "customfield_22900": {
                    "required": false,
                    "name": "Transfer Google Drive",
                    "fieldId": "customfield_22900",
                },
                "customfield_22800": {
                    "required": false,
                    "name": "Transfer all emails",
                    "fieldId": "customfield_22800",
                }
            }
        }
    ]
}

Welcome to the Make community!

transitions is an array, so you likely have to do

{{body.transitions[1].fields}}

2 Likes

unfortunately, it doesn’t work.

body.transitions.fields return Map from key and object

{
	"customfield_15309": {
		"required": false,
		"name": "Financial date of termination",
		"fieldId": "customfield_15309",
	},
	"customfield_14824": {
		"required": false,
		"name": "Date of last working day",
		"fieldId": "customfield_14824",
	}
}

And I need to iterate over these values to get name and fieldId.

{{ map(toArray(body.transitions[1].fields); "value") }}

Screenshot_2024-01-21_000114

2 Likes

@samliew
Thanks a lot for your help, it works

2 Likes

No problem, glad I could help!

If you have a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

Links

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

General

Help Center Basics

Articles & Videos

2 Likes