Skip to main content
All CollectionsHow-tosCertification Examples
Example Approach: Data in, data out
Example Approach: Data in, data out

In this article, we'll explore how to transform data throughout story building.

Yanni Hajioannou avatar
Written by Yanni Hajioannou
Updated over 2 weeks ago

Overview

Whether you're just starting out or are an advanced builder in Tines, transforming your data throughout your story is vital to success. In this article, we cover some common methods using simple scenarios on re-structuring event data within your stories to fit your needs.

Tines references

Before getting started, we recommend familiarizing yourself with the surrounding functionality this article covers:

Make it happen

Both sections below will be utilizing the following array:

{
"items": [
{
"name": "Gala Apple",
"type": "apple"
},
{
"name": "Honeycrisp Apple",
"type": "apple"
},
{
"name": "Macintosh Apple",
"type": "apple"
},
{
"name": "Blueberry pie",
"type": "pie"
},
{
"name": "Raspberry pie",
"type": "pie"
},
{
"name": "Strawberry pie",
"type": "pie"
}
]
}

Loops and tags

In this video, we look at how we can handle an incoming array and modify it to meet whatever criteria we need. The criteria in this scenario is to:

  • Add "is delicious" after every name key value" where "pie" is mentioned (i.e. Blueberry pie is delicious).

  • Capitalize the type key value.

We enable a loop in our event transform action to cycle through each object within our items array. We then utilize an if tag and the INCLUDES function to iterate through each looped name key value to check if "pie" exists. If it does, we add the "is delicious" string to it. If it doesn't, we just leave the name key value as is. We also use the CAPITALIZE function to capitalize the type key value.

We re-emit last event from the "Catch Results" action and see the results of our pie formatting in the events of the "Format array" action (and it's right, pies are delicious!).

Organize event data

In this video, we take a look at how we can take an incoming array and break it up based on a key identifier. In this example, we'll be leveraging the type key value of "Apple" or "Pie".

To create our categories, Apple and Pie, we utilize the explode mode of the event transform action. Since we only want to grab these specific values, we use our MAP and UNIQ functions to create a list array that includes one instance of each as the explode Path.

This creates an event for each category. Now that they're established, you can organize the original array. Using our WHERE function in a subsequent event transform action, we compare the original array type key values against the categories we created in the explode to see if there are any matches.

After re-emitting from a previous event, we can see how the final event transform action is just showing Pie!

Review the results

In conclusion, mastering data transformation in Tines is key to building effective and efficient stories, regardless of your experience level. By applying the methods outlined in this article, you’ll be able to tailor your data structures to meet your specific requirements, ultimately improving the performance and clarity of your story flows.

Did this answer your question?