Leveraging local values for calculations

Compound event transforms 

When building complex stories in Tines, you may need to perform multiple calculations or transforms on an event as it passes through your story. Tines allows you to define local variables within many action types. These local variables can store the results of calculations to reference in our action configurations.

Most of the time we'll have an event transform action that has a local variables section for some calculations and then it ultimately gets referenced in the builder*.

*builder: This is the area to the bottom of the properties panel where we can work with a variety of data values.

Defining local variables 

To define a local variable within an event transform action:

  1. Add an event transform action in your story

  2. Click the option at the bottom of the properties panel

  3. Select local values

  4. Configure the value

    1. These calculations will happen in the LOCAL section of the properties but can be referenced in the builder

  5. Reference the local value in your builder

    1. LOCAL.[value]

Click into Options on the bottom of an action.

Use the Local Values to run any calculations to free up space in your Builder.

In this example we start off with the below data payload. Our goal is to filter down to users who don't have "Smith" in there name. After that, we only want to display the email in the results. So using Local Values we run the initial REJECT, then referencing the LOCAL.temp value in the builder. In the builder we just put a MAP function to narrow down to only the email. By using local values we give ourselves a bit more space in the builder and leave the bigger calculations in the local values.

When creating the initial value in the local values the name temp is used. This is to indicate it is a temporary value, but it can be called anything you want.

{
  "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"
    }
  ]
}

Example of data calculations leveraging Local Values.

In the final data we'll notice that the local calculations are not included in the final event data. This is because the calculations stay within the action and are just referenced in the builder.

"local_value_example": {
  "message": [
    "johndoe@example.com",
    "franklinthomas@example.com",
    "janedoe@example.com"
  ]
}

Below are the actions if you want to paste them into your tenant and try it yourself.

{"standardLibVersion":"29","actionRuntimeVersion":"4","agents":[{"disabled":false,"name":"Kickoff","description":null,"options":"{\"mode\":\"message_only\",\"loop\":false,\"payload\":[{\"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\"}]}","position":{"x":6930,"y":-1335},"type":"eventTransformation","timeSavedUnit":"minutes","timeSavedValue":0,"monitorAllEvents":false,"monitorFailures":false,"monitorNoEventsEmitted":null,"recordType":null,"recordWriters":[],"form":null,"cardIconName":null,"createdFromTemplateGuid":null,"createdFromTemplateVersion":null,"originStoryIdentifier":"spring-flower-1346:b8be0d57110dfc118252609a77d1217f"},{"disabled":false,"name":"Local value example","description":null,"options":"{\"mode\":\"message_only\",\"loop\":false,\"payload\":{\"message\":\"=MAP(LOCAL.temp,\\\"email\\\")\"},\"local\":{\"temp\":\"=REJECT(kickoff,LAMBDA(i,INCLUDES(i.name,\\\"Smith\\\")))\"}}","position":{"x":6930,"y":-1215},"type":"eventTransformation","timeSavedUnit":"minutes","timeSavedValue":0,"monitorAllEvents":false,"monitorFailures":false,"monitorNoEventsEmitted":null,"recordType":null,"recordWriters":[],"form":null,"cardIconName":null,"createdFromTemplateGuid":null,"createdFromTemplateVersion":null,"originStoryIdentifier":"spring-flower-1346:b8be0d57110dfc118252609a77d1217f"}],"links":[{"sourceIdentifier":0,"receiverIdentifier":1}],"diagramNotes":[]}
Was this helpful?