General Functions
In this article, I’ll guide you through Make.com’s general functions, which allow you to apply conditions or manipulate arrays and objects within your scenario mappings.
It’s a bit techy, and you probably don’t need most of them, but some of them are handy to know.
Let me explain 🙂
Introduction to General Functions
General functions are tools for making your scenario mappings more dynamic 💪
These functions allow you to evaluate conditions, manipulate collections, and retrieve values from arrays and objects.
executionId (Variable)
The executionId
variable holds the ID of the current execution, which is useful for logging and monitoring purposes.
executionId
= 4372d8a52aea4c23ab2a7b2b029d3101
if
The if()
function compares two values and returns one of the two based on the outcome.
if(1=1;A;B)
= A
In the example above it returned A
because 1
is equal to 1
.
if(1=2;A;B)
= B
And here it returned B
because 1
is not equal to 2
.
ifempty
Returns value 1 if it is not empty; otherwise, returns value 2.
ifempty(A;B)
= A
ifempty(unknown;B)
= B
I find this especially handy to check if a variable is handy or not to create a fallback.
Hey ifempty(1.first_name;there)!
= Hey there!
In this case it would return “Hey there!” if the first_name
item is empty.
get
The get()
function returns a value from an object or array using dot notation for nested objects.
Imagine we have this array with 3 objects in it;
[
{ "name": "Alice", "age": 30 },
{ "name": "Bob", "age": 25 },
{ "name": "Charlie", "age": 35 }
]
And in this array, we want the name of the third object.
To do that, we use 3.name
in our function;
get(array;3.name)
= Charlie
Want the whole second object, which contains both the name and age?
get(array;2)
{ "name": "Bob", "age": 25 }
switch
The switch()
function in Make.com is a way to check a value against a list of possible matches and return a corresponding result based on the first match found. Here’s how it works:
switch(B;A;1;B;2;C;3)
= 2
So what happened, is that the function checked;
- Is
B
equal toA
? If yes, return1
- Is
B
equal toB
? If yes, return2
- Is
B
equal toC
? If yes, return3
B
is equal to B
, so it returned the value after it which is 2
.
omit
The omit()
function in Make.com helps you remove specific items from a collection (like an array or object).
Let’s say you’re sending data to an API (a service) that requires you to include only certain pieces of information.
If your collection has extra data that the API doesn’t need, you can use omit()
to get rid of those unnecessary parts, making sure the data you send is exactly what the API expects.
If you have a collection like this:
{
"name": "Emmah",
"age": 30,
"email": "emmah@example.com",
"password": "secret123"
}
And you want to omit the password when passing this to an API:
omit(1.collection;password)
{
"name": "Emmah",
"age": 30,
"email": "emmah@example.com"
}
See? We got the whole collection back, but this time without the password.
pick
The pick()
function lets you choose which elements of a collection you want.
An example;
{
"name": "Emmah",
"age": 30,
"email": "emmah@example.com",
"password": "secret123"
}
And we only want the name and email, not the age and password.
pick(1.collection;name;email)
{
"name": "Emmah",
"email": "emmah@example.com",
}
See? It’s the opposite of the omit()
function.
Instead of specifying what to remove from the collection, we use pick()
to create a collection with only the elements we want to keep.