hello everybody and welcome to the most comprehensive tutorial on mapping inm make. com available on the internet over the course of the next few minutes you're going to learn everything you need to know about mapping to get out there and start crushing your own scenarios I'm going to cover edge cases I'll cover a little bit of the theory behind it and essentially this is just going to be the end all Beall the only video you have to watch in order to understand this concept [Music] fully first things first there are only two things that you need to know about the map function in make. com before we dive into the scenario the first is a very simple pneumonic that I use anytime that I am mapping the pneumonic goes like this from a I need B where C is equal to D I understand that if you're not familiar with the map function or really pneumonics in general this may seem like uh pointless to you but I assure you if you just memorize this one sentence mapping gets extraordinarily easy as I will drill into your head over the course of the next 15 or 20 minutes the second thing is that mapping only works on arrays it does not work on other data types one of the most common questions that I get in my make.
com community is hey why is this map function not working and I inevitably will see that it is being used on a collection or maybe an object or just some data type that is not an array so mapping is an array function an incredibly potent and Powerful array function at that but it is an array function it's not a collection function it's not you know an object function it only works on arrays as long as you have these two things in mind and I will be running through the first one again and again and again over the course of the next five scenarios you will be fine and you will understand mapping okay so let's actually get into building this out in real scenarios I have a map playground set up over here with five different modules and each of these five modules are going to be basically like a test uh what we're going to do is we're going to solve all of these tests all of these tasks with mapping and I'll show you just how easy mapping makes all of this makes it extraordinarily straightforward now I've set these up here instead of just put them in five different scenarios for Simplicity my goal is I will make this available to you as a blueprint later on and then you can just go to the video description and then download this blueprint if you want to play around with this if you want to redo some of these examples here just for your own learning feel free um the purpose of this is for you to know everything you need to know about mapping okay so what are these parse adjacent modules well I'm not going to get super far into that because it's beyond the scope of this discussion but essentially this is just a quick and easy way for us to generate data structures with arrays in them so what I'm going to do is I'm going to link all of the rest of these array array items and then I'm just going to focus on this one which is our first test or our first task uh which is subscriptions with status equal pending and let me show you what I mean by that if I right click and then press run module and then I zoom in here to the data structure that's output you'll see that this is an array and this array contains five collections or five items in the array there's item one item two item three item four and item five and in inside of every item we have an email address then we have a subscription status then we have a full name and then that's our item we have three keys essentially with three values now hypothetically let's say instead of five items because I just did five items as an example um this array had 500 items and we wanted to select the item inside of this array specifically wanted to extract the email address for the item that had a subscription status equal to pending Maybe we building a big email blast for a client or something like that and we need to only be sending these to people with subscription status pending and for whatever reason we don't have access to this data right now we're getting it in make we can just very quickly run very simple and straightforward map operation that makes use of our nemonic to get it the reason why mapping is so powerful is it's not necessarily powerful when you have five items like this because you could see who is subscription status pending it's this good fell Bob Marley here really isn't paying his bills but if you have an with 500 items it takes you the exact same amount of work to solve this problem for an array with five items versus an array with 500 versus an array with 50,000 versus an array with 5 million you only have to write the string of code or make. com um you know no code logic basically once and then it just solves that problem for you forever and it also just allows you to do things in flows that otherwise might have taken you 20 or 30 different modules to do or um just takes away the makes your your flows a lot more flexible like you know we could theoretically Index this array and only get the third result right but that would require us knowing in advance that Bob Marley has a subscription status of pending and is the third result what if we add somebody new to this array well now we got to basically go back in time do all this over again and so mapping just allows you to eliminate that and just be so much faster um and it's something that I do on a daily basis to solve problems that people mention in my community and uh and and more specifically my clients so let's actually give this a go and let's actually see how we would map this in practice I'm just going to move this up here because it's going to make our lives a little bit easier in a moment and then I'm going to use a tool module called set variable I'm going to drag that up here connect it and I'm just going to call this our tester our tester is going to be where we're going to put in all the the mapping Logic the variable name for tester uh I'm just going to call this well let's actually think about our problem statement here our problem is that we want to extract email addresses with subscription status equal to pending so why don't I just call this pending emails I'm using camel case that is just where every word after the first is capitalized with the first letter but the first isn't guess that's why it kind of looks like a camel because the camel's head is down here and then the bump is is up there and this is just like a naming convention you could you know put an underscore if you wanted or whatever I just personally do this because I used to do software development and I was just a big a big into JavaScript which typically uses camel case anyway let's actually go into this variable value and let's run through our mapping function so in order to um instantiate the map function I just type map and then a little left bracket and it'll automatically pull it from the array value you can also go back to this array function list and then you could specifically select map it'll um add that little semicolon for you and then add that right bracket I'm just going to do it faster because I think it's faster like this and keep in mind you can do this for any function in make. com if it's a function the second that you put this little left bracket after the over verbiage it will um it will pop up in this little gray box if you try and do this with like um keywords like empty array wouldn't work which is why if you wrap them in two curly brackets each on the left side the left cly bracket the right side the right cly bracket you can also make that variable pop up but uh if you don't do that the variable is not going to pop up what I'm talking about right now only applies to two functions so anyway um for map specifically remember earlier we had that neonic right and that was from a I want B where C is equal to D well let me show you how simple it is to extract the data that we want from this in one second the way that mapping works is from a a is the array everything after the array you need to just write out in text not as a variable so from a I want B okay I want email where subscription status is equal to pending that's our map function this piece of logic essentially does exactly what I just wanted it to a moment ago and this piece of logic is capable of basically going out and getting hundreds of thousands of pending records and filtering through thousands and thousands and thousands of different email addresses if we needed to now in our case we only needed five and you see it found the email address Bob Marley a fly on my microphone interestingly enough Bob Marley example.
net but this works for literally anything this works for any um arbitrary length of array um and it also works for any other value that we want you know how earlier we said email what if instead of the email we just wanted the full name if you just write full name instead of email if you just replace the b in our neonic with full name and you run this again you see that now instead of it's saying um Bob Marley at example. net it says Bob Marley's full name so we can change the values that we want to extract and we can also change the criteria of the variables that we are looking to to pull so maybe instead of pending what if we want active I'm just going to replace that with active plus run run once well voila now we have three because there were three entries with subscription status set to active Dondo Alice wonder and Xavier the great so hopefully this seems pretty straightforward and the purpose of this is to make this seem as unintimidating to you as possible as we slowly ramp up the complexity in mapping but at least at the initial example as long as you use that pneumonic from a I want B where C is equal to D um you can just repeat that back and uh back and forth and back and forth in your head and rock yourself forward while hugging a pillow in a straight jacket uh and you know eventually you'll figure out how mapping Works God damn my dad jokes are out of control um anyway so that's subscriptions with status equal pending that's our very first example now why don't we put this away stick that in the corner where it belongs then we're going to go grab emails by user location equals Morocco I'm sure you guys can kind of guess what this is going to be doing this is going to be doing um a relatively similar example it's just instead of getting um emails with subscription status equal to pending we're going to be grabbing emails by the user location let's actually run this and let's see what pops up so if I go to the output which is the important part here and I zoom in you'll see that this is an array with five objects again except these objects look a little bit different previously we had first name uh full name and then we had email and then we had subscription status I think now we have first name last name email City and Country and we do this again for all five objects and I think that the name of the module makes it pretty self-explanatory but hypothetically let's just say our project for the day was we needed to pull out all of the email addresses with country equal to to Morocco that's what we need maybe again we're sending an email campaign or something like that or we're filtering out to do something maybe specific to people that live in Morocco how exactly excuse me would we go about doing that in make. com using mapping well it is the exact same thing all we have to do is use our mapping formula which is map and then from array I want email where country oops sorry I clicked on it this time I shouldn't have just going to write country is equal to Morocco and now I'm going to run this whole flow and let's see what our result is now I didn't change the title here it's still say pending emails but I think you guys still get my point we have Jane example.
com and FMA example. fun fact that I learned a few minutes ago ma is just the Morocco um top level domain name so that's pretty neat like in Canada here um the great w North we have uh uhca and I guess they have Ma I wonder why more people in the United States don't use the US domain name just because they have to dominate everything anyway so yeah that's that um let's hypothetically say instead of uh countries Morocco we want cities and we want the city to be equal to New York well all I do is I grab the city and then I believe it was just new space York so I'm going to give that a try press okay and then let's press run once let's see what happens yeah we got John at example. com because John lives in New York as per this data structure if you're wondering what this is this is just the um string that I had to feed this module in order to generate this example for us it's not hyper relevant to us this is the more relevant portion down here but let's just look for John yeah there you go we got a John Doe over here with the city of New York we could do the same thing for first names we could do same thing for last names we could do the same thing for example uh emails um and if you know you're wondering which is which is my logical question at this point hm why are you only pulling out the emails why are you pulling out the first name and the last name well I'll show you a quick little trick that you could use um in a subsequent example where you can actually pull out multiple um you pull out each of them individually and then you just stick multiple of them back together using the multiple variables module so that's our second example which is again quite straightforward no magic here as you see as long as you have that neonic down you will understand mapping um what I'm going to do is I'm going to unlink the second example stick this over here unlink this and then voila we're now looking at a third example and the purpose of this third example is to slowly ramp up the complexity a little bit and show you how this might look like if you instead of just trying to get one item so instead of just trying to get let's say like email addresses you're trying to get um a few simultaneously uh from an array instead let me show you what I mean well if I right click this and plus run module once minimize this big input array and then if I zoom into this data you'll see that our input array now looks like this we have a first name then we have a last name then we have an email then we have a type and then we have an array full of Interest hiking photography and cooking now hypothetically let's say you had sort of like a data example and you were interested in finding the interests of people that have high ticket sales types so maybe this is a list of customers in your database you for some reason tracked interests and you're looking to grab the interests of people that only have the type High ticket you're not interested in people with like Emma here who's low ticket who cares about Emma you only want people like Olivia and Tom and and Sarah who are high ticket and our goal is to basically get this big list of interests of people um that have that type equals High ticket so how would you actually go about doing this well it's really not any more difficult or different from what we've done so far let's just call this variable user interests let me zoom in here and show you how you do this in practice so this is our array structure here on the right right well you just do the same thing you map from array I want uh interests sorry I'm just adding a space here because I have a little keyboard macro that automatically adds a bunch of text now if you're wondering where I get this string interest from I mean you know why would I put interest here if this interest has like these two little left or right brackets the way to know what the variable name is to reference in mapping is you just Mouse over the little purple um variable picker and then you look in that little popup as you see it says interests and then there's little array um thing immediately to the right of it and then underneath it says raw and then it says interest well that raw section that is the raw text that refers to that variable and that's what you put in here but anyway I'm getting ahead of myself let's go back and do our pneumonic from array I want interests where type is equal to high ticket that's that quite straightforward let's give this a run and see what happens all right so we have a user interest array and as'll see we've pulled out three different sub arrays and each of these arrays has hiking photography cooking gaming technology entrepreneurship Fashion Beauty travel these are our lists of interests for everybody that had a type High ticket now I'm going to throw something else in here that I didn't talk about in the video description but map isn't the only valuable array function there are a variety of valuable array functions and one very valuable one that I find myself using every now and then is called flatten and so if you look at this array structure here we basically have three arrays all embedded inside of another array called user interests well if we flatten these arrays if we flatten the the top array what we're basically going to be doing is we're just going to be pulling all of these array objects out into one master array and maybe that's valuable because you just want to I don't know pump this out into an email to send to somebody for tracking purposes or D or something I don't know but if we feed this into another array function called flatten we give that another run we'll see that now we just have a list of nine um user interests so there going to be some edge cases where stuff like this is required for you um other edge cases where it's not really um but flatten and map you know I use these reasonably often in my own life um along with uh just running through here I use reverse every now and then um I use slice um I'll do D duplicate pretty often sometimes I'll use first and last um um that's that's about it off the top of my head but okay great that's example number three and as you can see these are slowly increasing in complexity in terms of the data that we're trying to grab what I'm going to do now is I'm going to jump up a complexity quite a bit and we're going to Target a more challenging example and this example is going to be grabbing emails by roll permissions and the reason why this is going to be a more complicated example is because this is going to require us to do to use nesting um keys and values we're essentially going have to index things if you're curious what that means let's just give this model a run let's zoom in and let's see what the data structure looks like so as the title here probably suggests we're looking for emails and we're looking to get specific emails that have a role permission that is not um read basically they're not allowed to read what does this mean in practice well we have a first name then a last name then an email then a roll and then down here we have a collection of permissions read false write true delete true this is Sophia Rossi who has permissions read true WR true delete false this is Jacob Nakamura which has read true WR false delete false and this is so low I can't even scroll um Olivia Sanchez and Benjamin Anderson all right so essentially what we're looking to do is we're just looking to pull let's just say the email address of somebody whose permission is equal to false essentially who's not true and I think there's only one person in this list so we're probably going to be pulling we're looking for Liam again if you imagine this was a list or an array with 5,000 entries this might be a little bit more valuable to you off the top of your head but uh I just want to show you guys in a way that where I can actually run through all of these elements make things very interpretable for you the question here and the big thing that's different from our previous example is notice how instead of us just looking for an object or instead of us just looking for a key and a value pair this is actually nested we have another collection called permissions and inside of permissions we have read false so we basically have to go one level deeper that's okay and this normally trips up a lot of people but I'll show you again a very simple and easy way that you never have to be tripped up by this again so what I'm going to be looking for is I'll be um I'll just saying false read false read emails let's just do that and then let me make some space here and then zoom in so we could see exactly what's going on with this array object uh array object that's funny um exactly what's going on with this array so you see it's array first name last name email roll permissions read write delete so what we want is we want entries where read is set to false and the data I'm going to be pulling out is going to be the email so I want emails where that is set to false no problem let's just use our pneumonic we're going to map from array and then what we want to pull is I want uh from array I want emails so I'm going to go email and then yeah sorry that's my little thing here that instantly pops up my um my email address nicklis drive at gmail.
com don't send me nicely written letters uh so from a I want B where C is equal to d right so where read is equal to D the question is how do we actually get read well it's really simple in make. com the way that things work is if you have a collection you're trying to get an OB um a a key within the collection you just have to write the parent key dot the child key so I would in this case write permissions. read the way that I know this is I moused over permissions I saw the raw it said permissions and then I moused over read I saw the rod said read so from array I want email where permissions.
read are equal to and what are we looking for we're looking for false so I'm just going to type false in there and now let's give that a run let's see what happens and as you see we pulled out Liam and example. com and if you guys remember Le was the only one who had the read set to false in that case but we could try something different maybe instead of permissions. read is false maybe we want permissions.
read is true how about that let's give that a try what do you guys expect is going to happen here well we're probably going to pull four people out right and we did Sophia Jacob Olivia Benjamin of the five these four had reads set to true but why don't we try looking for another thing that we could do maybe instead of permissions. read we want permissions. delete right so why don't we try that let's go permissions.
delete and we want permissions. delete is equal to true so let's give that a run so you see here we got one because it was only Liam whose permissions. delete was set to true now let me do uh something else I'm going to write and um make this an even more complex more contrived example because I want to show you guys how deep we can go here what if there was a second permissions object and inside of second permissions you had x equal to true I think I believe that'll be right if not I am dumb let's give this a run okay awesome so now we have two objects and what I have to do in order to make this example actually relevant is I just have to go through each of these then I have to write the second permissions X is equal to True X is equal to True X is equal to true and then X is equal to true and let's make this one false and let's make that one false let's just give this a run here okay great I think everything was fine here looks like it so now hypothetically let's try and Nest one level deeper let's say here inside of permissions and then second permissions what we're looking for is we only want to pull the emails of Records where permissions do second permissions dox is equal to false probably seems like a mouthful right but it's okay as long as we follow the same structure that we had before will be fine let's zoom in on our array structure here and then let's use our pneumonic so from array I want email where permissions let's just Mouse over this make sure that raw is permissions yes it is and then second permissions dot second permissions let's see what this is this is just X so dox is equal to false let's give this a run as you see we got two records and if you remember three of those were true that I just quickly created and two of those were false these were the two that were false so as you can see we can go arbitrarily deep into extraordinarily nested structures very very easily simply by keeping in mind um dot indexing where basically we have the parent key dot the child key dot that child's key do that child's key all the way until you get what you're finally looking for and you can go arbitrarily deep doesn't really matter matter but all right that is our fourth example why don't we go to our fifth example and I'll show you how this structure that I'm doing can work if you wanted to pull out multiple Keys instead of just one key and if you wanted to make use of what I just talked about in my previous video if you guys have another chance to check it out um iterators and aggregators which sort of adds another level of complexity to this whole thing but all right in this case we have product sold in the last month let's right click Prest one this module only let's look at the the array what do we have here we have an array with items called pro-001 name wireless headphones category Electronics price in stock true sales info sold in last month true number of sold last sale this is sort of the structure of this you can imagine this is like some e-commerce store now what we're looking to do is we're looking to grab all the products that are sold in the last month but we don't just want to pull one thing like before you know we were just pulling the email we're just pulling the ID we actually want to pull two things so I want to pull the pro-2 and I also excuse me I also want to pull the price so I want to do two things not just one so how exactly would you do that with mapping well fortunately mapping only allows you to pull one thing right doesn't work you can't just I don't know you can't type in two things here you know I wish you could that' make my life a lot easier but uh you can't you know from array I want to pull ID and name where um I don't know sales info.
sold in last month is equal to true like how great would it be if you could just click run once and then this would output everything you need well it doesn't so what you have to do instead is you have to do a workaround where instead of setting one variable you're actually setting multiple and then you aggregate them all together into the target object that you're looking for does that sound like French to you um great French is a beautiful language I'm I'm thankful no uh no problem we're going to solve this I'm going to go to tools instead of set a variable I'm going to set multiple variables okay and what I'm going to do is my very first variable name is going to be ID then my second variable name is going to be uh price for the first variable I'm going to map this array so from this array I want the ID where sales info. soldin last month is set to True okay now if I just give this a run what happened here well all ID array is filled with three entries product 1 three and five just because those are the ones that happen to correspond to the logic that I put out the price is empty because I didn't fill it in but notice how essentially we're going to be getting an array so what if we got an array of IDs and then an array of prices how would we combine them well I'll show you very very Nifty little trick let's do the same thing for price now and now that we know our neonic this is going to be super straightforward we're looking from array to grab the price where sales info do sold in last month is is set to True it'll be the exact same logic as this I'm going to click okay give this a run then I'm going to look at what's in here we have product o 179. 99 product O3 39.
99 product o5$ 12. 99 and now let's say I need to have both of this data I need to combine them somehow all right so unfortunately I had a call that I had to deal with and it has uh taken me a little bit longer than I expected however let me walk you through what the logic to actually get this done looks like and then you can actually just copy the um little snippet of code essentially and then just reuse it anytime that you want to create uh the same sort of structure that I've done so we have the product sold in the last month over here uh if I run this you see that we generate the array that we talked about before right with sales info sold and last month all that stuff and then basically what we're doing is with a set multiple variables module we have variable names so IDs and prices so now we're we're deconstructing or we're mapping two separate arrays now with one item in each but those two items correspond to each other line item by line item we are then feeding in one of these into an iterator now the cool part about feeding something into an iterator is that when you feed it into an iterator you get what's called a if I run this you'll see you get the bundle order position so one two and three and this bundle order position is going to allow us to track which element in the array of the other array we can use to index the specific item um so again this is some pretty advanced stuff you don't need to know how to do in order to do most of what you can do in make.