In this article you will learn…

  • How to use "Outputs" from a Connector function in an app

Arrays and objects are two popular data structures that are used in many programming languages. Tulip utilizes these both of these data structures in connector functions:

  1. When a SQL connector function outputs multiple rows, the output is sent to an app as an array full of objects
  2. When a SQL connector function outputs a single row, or a HTTP connector function has any output, the values are stored as key/value pairs in an object

Objects can only be created automatically upon the successful completion of a Connector function.

This guide will show you how connector function outputs are automatically organized. Then, you will see how to use these outputs in apps.

Collecting Output from Connectors

Imagine that you want to pull all the data about a specific operator from a SQL database based on their Tulip badge ID. 

To do this, you would write a SQL Connector function that takes badge_id as an input, and saves all the operator’s information in an output. In this case, the output is called group_name. This is what it would look like:

This function has one output, group_name, which is stored as a string. This is based on the “Text” label in the Outputs section.

In fact, when you create a Connector function, there is no option to store output as an array or object.

So, you must store it as “Text”, then manipulate it in the Trigger Editor.

Run this function in the Trigger Editor to store the output in an object.

  • "Run Connector Function" connector: "SBD - Test" "Operator Navigation"
  • badge ID: "Static Value" "text" "2222" and save result as: "Variable" "test_var"

In this case, you are using a value of 2222 as the input, and storing output in a variable called “test_var”.

Using Objects In An App

In the example above, we took an output called group_name and then saved it in a variable called test_var. The App Variables view show that this variable is actually an object with one property called “group_name”.

In fact, if the Connector function had multiple outputs, each one would be stored as a new property of the object called “test_var” that was created in the Trigger. This allows you to organize all the outputs of one function call in one place.

You can test out the outputs of the function by adding some Variable text to your app, and then selecting the variable from the Widget tab of the Context Pane.

In this case, we have a variable called "Order Details" that stores an object with 5 fields:

  • orderPlaced
  • quantity
  • address1
  • address2
  • address3

As soon as you select the object from the Variables search box, you will see all 5 fields populate in your app with labels based on the names of the properties. You may need to expand the variable text field to see all of them at once.

Displaying Objects

If your object has multiple properties, you may want to show all of them at once in one step of your app. This is easier than creating new variable text for each individual property.

To reorder/remove individual properties from the object, click the x or the grid symbol on the property in the Context Pane.

To change the number of columns, use the Columns option in the Context Pane.

To change the display of the labels and values, adjust the color and font size in the Context Pane.

To see how this data will be shown the operator, run the app in the Player, and you will be able to see the whole object. Values will be included if you first run the Connector function that gathers the values.

Reviewing All Object Variable In An App

In order to manipulate a data structure in an app, it must be already stored as a variable. You can see your existing variables by entering the Context Pane in the App Builder, and selecting the Sigma symbol next to “Variables” in the App tab.

Objects will be shown with the universal object symbol, “{}”.

Further Reading

Did this answer your question?