Data manipulation

Formulas and functions in Tines 

Throughout Tines, we can use formulas and functions to modify and transform data as it flows through our stories.

When we are clicked on an action we'll find that in our properties panel to the right we can reference data. We can do this by going into the value section in the builder and clicking "+" and then the "value". This will pull up the formula builder where we can:

  • Reference event data from previous actions.

  • Apply functions.

The ability to access the formula builder is accessible in other segments of the platform as well. Essentially, anytime you see the "+" when clicking into text like when working on a page.

Useful functions

Let's review some useful functions:

MAP function 

The MAP function creates an array by extracting the values of a named property from an array of objects. This is helpful when you only need specific values from an array.

Here we have an example of an array from an action called kickoff with an email, name, and IP object within each item in the array. We could write a MAP function that gives us just the email by doing the below.

(MAP(kickoff,"email"))

{
  "kickoff": [
    {
      "email": "johndoe@example.com",
      "name": "John Doe",
      "ip": "192.168.1.1"
    },
    {
      "email": "lousmith@example.com",
      "name": "Lou Smith",
      "ip": "192.168.1.2"
    },
    {
      "email": "mike@example.com",
      "name": "Mike Smith",
      "ip": "192.168.1.3"
    },
    {
      "email": "franklinthomas@example.com",
      "name": "Franklin Thomas",
      "ip": "192.168.1.4"
    },
    {
      "email": "janedoe@example.com",
      "name": "Jane Doe",
      "ip": "192.168.1.5"
    },
    {
      "email": "gerg@example.com",
      "name": "Greg Smith",
      "ip": "192.168.1.6"
    }
  ]
}

The result would look like this:

[
  "johndoe@example.com",
  "lousmith@example.com",
  "mike@example.com",
  "franklinthomas@example.com",
  "janedoe@example.com",
  "gerg@example.com"
]

WHERE function 

The WHERE function selects all elements in an array where the key has the given value. This is useful for checking values in an array.

Syntax: WHERE(array, key, value)

APPEND function 

The APPEND function joins two pieces of text together. This is helpful when you need to concatenate strings.

Syntax: APPEND(text1, text2, ...)

CAPITALIZE function 

The CAPITALIZE function makes the first character of text uppercase and converts the remaining characters to lowercase. This is useful for reformatting data like names.

CAPITALIZE(text)

SIZE function 

The SIZE function returns the number of characters in text or the number of elements in an array. This is helpful for triggers and conditions.

SIZE(text_or_array)

You can find the full list of formulas and functions in the Tines documentation:
https://www.tines.com/docs/formulas/functions

Try adding some formulas to your next workflow to transform and modify data as it flows through your story!

▲  How-to: use the map function
Was this helpful?