Referencing data

Formulas are all about referencing and transforming data. Let’s see where that data can come from.

From upstream actions’ events 

Say we’re evaluating a formula's expression in Action B, which is downstream from Action A. Perhaps Action A had fetched a list of users from a remote API.

Now, Action B can make a reference to that data – for instance to count it:

COUNT(action_a.body.collections.users)

Simply refer to the snake cased name of the upstream action to access its data.

From resources 

Use the special RESOURCE key to access data residing in resources. Let’s say we have a text resource "Domain name". The following expressions would fetch it:

RESOURCE.domain_name

If you want to dynamically reference resources based on a variable, there are a couple of ways to do so:

# Upstream action payload
{
  resource_name: "domain_name",
}

# Downstream functions
RESOURCE[upstream_action.resource_name]
GET(RESOURCE, upstream_action.resource_name)

From credentials 

The CREDENTIALS key works identically to the previous example, for fetching credential tokens. (Note: because these are inherently sensitive, we’ll never output a preview value in the formula builder when working with credentials.)

CREDENTIAL.example_api_key

If you want to dynamically reference credentials based on a variable, there are a couple of ways to do so:

# Upstream action payload
{
  credential_name: "example_api_key",
}

# Downstream functions
RESOURCE[upstream_action.credential_name]
GET(RESOURCE, upstream_action.credential_name)

Metadata 

The META key exposes a useful set of information about the current environment. Here’s the full data structure it generates:

"tenant": {
  "domain": "example.tines.com",
  "name": "example"
},
"team": {
  "id": 123,
  "name": "Example team"
},
"story": {
  "id": 123,
  "name": "Example story",
  "key": "example_story",
  "is_test": false
},
"action": {
  "id": 123,
  "name": "Example action",
  "key": "example_action"
},
"story_run": {
  "id": "fc7b6392-b602-465b-8f58-ee07d33fa80e"
}

So, for example, to access the name of the current story, you could use:

META.story.name

Info 

The INFO key exposes relevant information about credentials, resources, and records.

Credentials: Access a credential's name, ID, and metadata values.

INFO.credential.example_credential_name.metadata.example_metadata_key

Resources: Access a resource's name and ID.

INFO.resource.example_resource_name.id

Records: Access a record's ID, name, and fields. For each field, access its ID and name.

INFO.record.example_record_name.fields.story_name.id

Cases: Access case sub-statuses. For each sub-status, access its ID and name.

INFO.cases.statuses.sub_status_name.id
Was this helpful?