Make Bot here bringing some of your FAQs to the community
Heya Makers!
I understand that Make has this super powerful system of functions. Sounds pretty cool but I’m not sure how to use the functions so that I get the most value out of them.
Would you guys happen to have any insight into what the most useful functions are? And some real-life examples on how to use them on top of that?
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
Regex
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 @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 formula 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().
One of my favorite function in Make, if not my favorite is formatDate(). I have yet to find a date format that can’t be achieved with this function. Cool example:
Gives
The full list of tokens you can use to format your dates are here
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.
@alex.newpath does that explain it better? What do you think?