When you're building workflows in Tines, you often need to make decisions based on your data. Should this purchase order be approved? Does this employee need manager approval? Is this form complete? Logic functions help you answer these questions by checking conditions and returning true or false answers.
Think of logic functions as the decision-makers in your workflows. They review your data, verify if certain conditions are met, and assist you in determining the next steps.
Tines offers multiple logic functions, but we'll explore the following in this section:
IF: Returns different values based on whether a condition is true or false.IS_BLANK: Checks if a value is missing or empty.IS_PRESENT: Checks if a value exists.
IF: Choose between two values
The IF function checks a condition and returns one value if it's true, and a different value if it's false.
Basic syntax
IF(condition, value_if_true, value_if_false)Example
We just received some data on purchased items via an HTTP Request action called "Get Order":
{
"order_id": "I-492",
"total_items": 7,
"cost": 149.99
}Now, we want to determine if the order is eligible for free shipping. Let's say the order qualifies if it's over $100 USD. In the next action, let's set up the following IF formula within the Value pill:
IF(get_order.cost > 100, "Free Shipping", "Standard Shipping")get_order.total: The upstream reference path to the total item.> 100: Greater than 100 (100$ USD for our example)Free Shipping: The value to return if the condition is true.Standard Shipping: The value to return if the condition is false.
So for a $75 order, this formula would return "Standard Shipping". For our order that we pulled earlier, the formula would instead return:
Free Shipping🪄Tip
IS_PRESENT: Check if something exists
The IS_PRESENT function checks if a value exists and has content. It returns the boolean true if a value is present and false for values like false, empty text "", empty arrays [], empty objects {}, and null. Use IS_PRESENT when you need to confirm that a value exists.
Basic syntax
IS_PRESENT(value)Example
We want to check if a customer includes their company name in their user data (via an upstream action called "Get Customer"):
{
"name": "Jane Smith",
"email": "jsmith@company.com",
"company_name": Tines
}Here's how we would check:
IS_PRESENT(get_customer.company_name)For our example data, this would return the boolean true:
trueIS_BLANK: Check if something is missing
The IS_BLANK function is the opposite of IS_PRESENT. It checks if a value is missing, empty, or false. It returns the boolean true for values such as false, empty text "", empty arrays [], empty objects {}, and null.
Basic syntax
IS_BLANK(value)Example
Before processing a registration, we can check if a user's phone number field was left blank (via a connected, upstream action called "Get User"):
{
"user_id": "123",
"email": "mwillow@company.com",
"phone_number": ""
}Here's how we check:
IS_BLANK(get_user.phone_number)The result: The formula returns the boolean true, as the phone_number value was empty:
true