I know I am missing something, but have been trying to get this going for a while with no luck. I am doing an API call to BambooHR, which returns the following:
What I want to do is search for a match on the name field and return the value of id. I have tried using map with no success. Any help appreciated.
Welcome to the Make community!
Can you provide us examples of what you have tried?
To allow others to assist you with your scenario, please provide the following:
1. Relevant Screenshots
Please share screenshots of your scenario, any error messages, relevant module fields, and filters in question? It would really help other community members to see what you’re looking at.
You can upload images here using the Upload icon in the text editor:
2. Scenario Blueprint
Please export the scenario blueprint file to allow others to view the mapped variables in the module fields. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.
3. Output Bundles of Modules
Please provide the output bundles of the modules by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.
A. Upload as Text File
Save each bundle contents in your text editor as a bundle.txt
file, and upload it here into this discussion thread.
B. Insert as Formatted Code Block
If you are unable to upload files on this forum, alternatively you can paste the formatted bundles.
These are the two ways to format text so that it won’t be modified by the forum:
-
Method 1: Type code block manually
Add three backticks ```
before and after the content/bundle, like this:
```
content goes here
```
-
Method 2. Highlight and click the format button in the editor
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.
Following these steps will allow others to assist you here. Thanks!
Hello! Welcome to the Make Community!
The format BambooHR returns is complex because it’s not an array but a list of collections with different names (corresponding to the IDs).
What you need to do is to use the toArray() function on the “body”. Once it’s done, you will get an array with a Key (that will have the value of the ID), and a collection called “value” with all the data you need.
From here, you have 2 options, depending on what you want to achieve:
1- if you want to get the id (key) for which name is exactly a string, you can use the map function.
2- if you want something more sophisticated, you can use the Iterator and then Aggregators and filters on the bundles.
For option 1, it could look like this
toArray function
map function (I did from a sample I built)
Result
I hope it helps
Benjamin