a. This is a nested function that computes the split() function first. The split function takes the input string and outputs values based on the “where to split” argument; in this case, giving us a first name and last name value.
b. The get() function returns the value that you specify by the order; in our example, first name was split first, so using “1” will give us the first name and using “2” will give us the second name.
c. When mapping this into a field, we typically have either a “Full name” or “First name” and “Last name” separately; this gives us those separate names with a “Full name” input
But lets say you have a full name which doesn’t just have 2 sections and could be different each time. In the netherlands we have a lot of middle names such as mine: Bjorn van den Akker.
In this case the above won’t work, and it’s “better” to use something called RegEx. RegEx (or Regular Expressions) allows you to extract or replace text according to a certain pattern.
You can use the following regex to extract first name and last name from any kind of dynamic full name:
Brilliantly put, @datalytyks! Thanks so much for sharing this with the community. This is eternally helpful information!
Thanks for jumping in with the visuals and the additional functions @Bjorn.drivn! I’ve heard stories about people struggling to work with names that consist of more than two parts so this is super valuable input.
One of the most useful functions in Make is “mapping”. Mapping is used to get data from the output of one module and use the data in the input of another module. Mapping sometimes involves filtering collections and arrays using a combination of functions: the get() and map() functions. There is an excellent write up on this which is a must read for anyone who wants to use Make effectively.
If you don’t want to read the article here’s a short preview:
Imagine you have a bundle of data that looks like this. You want to get the “no” value of the corresponding key in the array Meta data
This expression will obtain the value of the Value item of the element with keyMeta data ID item value equal to 20642 :
Note that the get() function retrieves the first item in the returned array from map().
You may be asking why the second and third argument are value and id where the actual display is Meta data ID and Value. This is because the raw names of each of these keys is different than the display name. Hover over each element in the mapping “star” panel and see what the raw name is. This is what you should use in the map() parameters. Do not click on these to map them as it will not work. This is a common mistake.
I recently had a case where I needed to strip through multiple layers of Arrays and Collections.
TL:DR, I used nested “map” and “flatten” functions.
My goal was to get a unique array of email addresses to iterate over.
My conerns were that the output from the trigger module would have hundreds of bundles, and I didn’t want to blow through a lot of operations.
I used an aggregator on the value I wanted from the first module to process together all the bundles in 1 operation. You can see the input and output structures below. Again, the output has the email addresses buried deeply within arrays of collections, but at least now there is just one output bundle:
The function that I used to strip this all apart is essentially just to roll back the different layers. First, it maps the array using the “attendees” to extract those as a separate array. Next, it flattens that down to make it a simple array, and finally it maps the email address field. For my own purposes, I also included a deduplicate function on the result, since I knew I would have lots of duplicates (for example, from our own staffmembers’ email addresses. You can see the function and the result below:
One issue I ran into was that some meetings didn’t have an attendee array, and the functions would throw errors when they tried to map a null value. To get around this, I added a filter after the trigger to exclude those bundles, since I didn’t care about them.
Jumping one year into the future
We’ve got an API that is responding with a very awkward data structure. The structure cannot be changed by the API provider, so we have to manipulate it. The biggest problem is that the API is sending all values as arrays. This is creating challenges when trying to do basic tasks with this data, For example, filter “exist” will always return true (even if array is empty), length will return wrong values, etc. Another strange thing is that Make sees some of the empty arrays as "\r\n ".
Any ideas on how to elegantly manipulate this into a more workable data structure?
Here’s the response from the API:
This is pretty common actually @LH . All APIs respond with Arrays and collections within the arrays – it’s just in your case it is nested a bit more than usual.
You will want to read about the map() function and using get() to extract what you need from it (or the new first() function). Start here and experiment so you understand exactly what you need to do.
As for the data in the values of the collections you can manage those with the text functions and trim out the white space if necessary. You’re just going to have to deal with what you are given and Make will help you do that.
I suggest heavily with starting with simple API responses with less data not to overwhelm you when playing with the setvaribable module and extracting data from the output bundles.
This is huge. Thank you!! I have run up against this trouble often when I deal with linkedPulseIds in Monday.com, and have oscillated between doing costly operations to grab the data to awkward work arounds that make life more complicated…and now this!! In one simply operation!! Thank you, thank you, thank you. Stumbled on it with the search of “Deeply Nested”. I think this post should be required reading for everyone starting with Make. the get(map()) works for some things, but the flatten is key and very helpful.
Needed to ask Bing how your second bit of regex worked. It was very helpful:
This is a regular expression that uses a positive lookbehind (?<=...) to match one or more characters .+ that come after a word \w+ followed by a space \s at the beginning of the line ^. In other words, it matches everything after the first word in a line.