Construct

Creates an object based on a set of user-defined inputs.

Input Fields

  • (user created fields): Create one input for each key that you want to create in the output object. The input names become the key names in the object that gets created. Each input can be set to any type, including object or list. The values are populated using the output fields dragged in from prior cards in your flow.

Output Fields

  • output: The newly constructed object.

Example

As an example, consider the scenario where you want to create an object that represents a customer. This customer object has four keys: First name, First name, Age, and Loyalty. The last key indicates if the customer is a member of your loyalty plan.

With the function card, create inputs for each key name and set the input types. Both name fields default to text, but Age should be a number and Loyalty should be set to a true or false value:

Then you can add the construct function to your flow and drag any fields to the card inputs. For example, when the flow runs for your customer named Jane Smith, age 29, who is a loyalty member, you'd get an output object like this:

Copy
Output object
{ 
"First name": "Jane",
"Last name": "Smith",
"Age": 29,
"Loyalty": true
}

You can build any object using this function. You can set the inputs to any type, including lists.

As an advanced use case, you might want to define one of the keys as an object that gets constructed at runtime. To do this, you can use two object constructs. First define the inner object and then define a second object with one of the keys as an object type. Finally, drag the output of the first card (which is an object) onto the object key of the second card.

Related topics

Functions in Workflows

Workflow elements