Open Navigation

Data Storage Helper

Store data and create local variables in Tray
On This Page


The "Data Storage" connector on Tray allows you to get and set data. It works using a key-value store, which means that you can set any type of value you like, using a key to retrieve it. At its core, Data Storage is how we create local variables in Tray.

Example Usage

You can find an example of this helper being used in the Saving and Retrieving Data Tutorial


Set Value"Set a value in the chosen scope, under a specified key."
Ex. A: Initialize a counter to zero
Ex. B: Update the value of a counter you initialized earlier in the workflow
Get Value"Get a value set earlier in the chosen scope, under a specified key."
Example: Retrieve the current value of a counter you are using in your workflow.
Add to Collection (advanced)"Add a value to a collection in a specified scope."
Overview: Think of a collection as an array. We wish to store a 'collection' of items under a single alias.
Example: In combination with boolean logic, store a list of users who are inactive in a Collection 'Key: inactive'.
Shift Collection (advanced)"Get and delete a subset of values from a collection."
Overview: Think of this as the Javascript operation 'array.shift()'. Remove the first item from a collection of items, and return it.Example: In combination with the 'Loop Collection' node, return the first 5 items from the Collection 'Key: inactive' by shifting the Collection 5 times (a single element is returned each time).


Unique identifier to reference the location data is stored. Use a unique key for each Data Storage element you wish to use. You may use a single key up to 3 times, as long as each instance is in a different scope.

We recommend using ' snake_case' when creating your key.


Data element to pair with a given key.

For example, you might want to save the last time you ran a "sync" between two systems, like this:

Key: last_sync_time, Value: 017-02-22T22:29:22+00:00


The namespace and closure convention for Data Storage. You may use a single key once in each scope.

Current RunAccessible during a single iteration of a workflow
Example: You wish to create a local variable to store a count of items recorded while iterating through a loop.
WorkflowAccessible during all iterations of a single workflow
Example: You wish to record the number of users who have submitted a form using your workflow.
AccountAccessible during all iterations of all workflows associated with a single user account
Example: You wish to assess the volume of API calls that are running through Tray for your organization. You create a single Data Storage element to capture this information for all of your workflows combined


Shift Collection.AmountSpecify the number of data elements you wish to remove from the front of the collection.

Getting and Setting

To initialize a data storage key, Set it to a specific value.

To access the value that you have set, you must perform a Get operation.

Think of this as performing a database query. You must first insert the row. Once the row is inserted, you may grab the row and access the data from that row.

If the given key is not found then the default value will be returned - which can be set to anything. This is really useful for initialising new lists, strings, or counters that you plan to add things to. For example, now the first Get call for a new key can return an empty list, empty string, or 0, rather than null.

Was this article helpful?
On This Page