Need help with complex Array filtering / Mapping

I am making an API call to pull a list of projects from my Teamwork.com account. Right now I get all of the project results returned (expected), but I want to filter by these results, to only proceed with the project that has a custom field which matches a passed value (from a prior step). Currently, I created two Iterator steps to iterate on the project array, then the custom fields array. This allows me to add a filter based on a matching custom field, proceeding only when there is a match (working). However, this doesn’t help me accomplish my goal of being able to actually map the “ID” of the project that contains said matching custom field, in a later step.

I’ve attached my JSON response from my API Call. As an example, I want to retrieve the ‘id’ field, when the customFields array (subarray of Projects) contains a value of ‘01exampleID1’.

(Would return an id of ‘1135504’ for that customFields value example)

Sample JSON.txt (27.3 KB)

Hi @mattb

Please try map function {{map(16.customFields; “id”; “value”; “01exampleID1”)}}

If you want to retrieve all project data containing “01exampleID1,” please use an iterator before mapping the data. Additionally, use a filter to exclude any data that doesn’t meet the requirements.

Input:



Output

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

2 Likes

Hey, unfortunately this doesn’t solve my dilemma. I am needing to retrieve the “id” field of the primary array (NOT of the ‘customFields’ array). Hence my dilemma explained in my original post. How would I go about pulling the id from the bundle on a separate array, when the ‘value’ of the ‘customFields’ matches up with my search criteria?

Please see this screenshot for a clear example:

Well good news. I found a solution! Your post had me thinking about the filter, so I created a filter between an iterator and aggregator step to aggregate the array for custom fields, along with the primary id, and was able to pass only the value that matched, allowing me to set the id value in the set variables step. Solution below:




2 Likes