Skip to main content
Question

Access Nth element from an array (nested, or otherwise)

  • June 23, 2025
  • 4 replies
  • 35 views

I’m having problems trying to access Nth element of an array within a bigger JSON object returned by a Zap.

 

For context, I’m using Salesforce API Request (Beta), and calling the composite endpoint, which allows me to call different endpoints within Salesforce subsequently.

 

The Salesforce Zap returns this:
 

 

Where data is a child of “response”, and here’s how it would look as a JSON:

 

{
"response": {
"status": 200,
"headers": {},
"data": {
"compositeResponse": [
{
"body": {
"id": "701PP00000rOSfnYAG",
"success": true,
"errors": []
},
"httpHeaders": {
"Location": "/services/data/v62.0/sobjects/Campaign/701PP00000rOSfnYAG"
},
"httpStatusCode": 201,
"referenceId": "newCamp"
},
{
"body": {
"attributes": {
"type": "Campaign",
"url": "/services/data/v62.0/sobjects/Campaign/701PP00000rOSfnYAG"
},
"Id": "701PP00000rOSfnYAG",
"IsDeleted": false,
"Name": "Test Webinar"
},
"httpHeaders": {
"Last-Modified": "Mon, 23 Jun 2025 12:57:06 GMT"
},
"httpStatusCode": 200,
"referenceId": "campDetails"
}
]
}
}
}

 

In subsequent Zaps, I am trying to use field mapping to reference specific keys from each element under the array in “compositeResponse”

 

I have tried

 

{{_GEN_1750679257710__response__data__compositeResponse[0]__body__success}}

{{_GEN_1750679257710__response__data__compositeResponse__0__body__success}}

And different variations of that, also tried dot notation, but it’s not picking them up at all.

The only one that works is {{_GEN_1750679257710__response__data__compositeResponse[]body__XXX}}, but it’s not suitable for my case because it apparently aggregates those key-value pairs across all elements in the array in a comma-separated string.

 

I could probably fix this by using a Code step or otherwise, but I want to figure this out as it’s much simpler and straightforward than having to add another step.

 

Thank you for your help!

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

4 replies

Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • 34001 replies
  • June 23, 2025

Hi ​@yIdris 

The raw JSON should be returned from the API request for you to use in a Code step to parse the JSON however you want.

Code help: https://zapier.com/apps/code/integrations#help


  • Author
  • Beginner
  • 1 reply
  • June 24, 2025

Thank you for answer, Troy. But wouldn’t there be a way to simply access an array element from the screens I’ve shared? I am trying to minimize the number of steps I use.


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • 34001 replies
  • June 24, 2025

@yIdris 

Help link about custom pill mapping.

Check the examples at the bottom.

 


SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • 9654 replies
  • July 14, 2025

Hey ​@yIdris, just checking in! How did you get on with the custom pill mapping guide Troy shared? Did help you to get the right field selected, or did you end up using a Code step? 

Keep us posted on how it went, want to make sure you’re all set! 🙂