Working with Operations
Overview
Outputs determine what data will be returned when an operation runs in a form or workflow. This guide provides examples of output formatting and how it affects the data returned.
Object Mapping Examples
The examples in this section all use the "Object Mapping Example" connection, which has a Base URL of https://api.sampleapis.com/imagcodingresources/codingResources/1
. No authorization credentials are required.
The Raw section displays the entire request payload in all cases, but this data is only available when testing operations in the Space Console. In a form or workflow, you'll need to create outputs for the parts of the data you want returned. The Outputs section represents these results.
Example 1: No Output Defined
Leaving the Outputs tab blank returns an empty Outputs section, indicating that no data was returned.
Example 2: Passing Through the Entire Response
You can pass through an entire response on the Outputs tab to return the data for the specified key-value pair. In the example below, the only output specified is data:body
. This returns the entirety of the body
content.
Example 3: Returning Individual Properties
To further limit the data returned, you can specify individual properties for the response. In the example below, the following key-value pairs are defined:
body.id
body.description
body.url
The outputs are returned as objects, so their properties will be unsorted. After the operation has been saved, the Outputs tab will show the defined outputs in alphabetical order.
Example 4: Manipulating Data into a New Structure
You aren't limited to returning outputs one line at a time. You can use JavaScript expressions to return data in the format that suits your needs.
In the example below, the following key-value pairs are assigned:
resource: { "id": body.id, "link": body.url }
description: body.description + ". Topics include: " + body.topics.join(", ") + "."
metadata: "Levels available: " + body.levels.join(", ") + "."
As in the previous example, the Outputs section returns the requested data in alphabetical order.
List Mapping Examples
The examples below all use the "List Mapping Example" connection, which has a Base URL of https://api.sampleapis.com/imagcodingresources/codingResources
. No authorization credentials are required.
Example 1: Passing Through the Entire Response
In the example below, the only key-value pair defined on the Outputs tab is list: body
.
Example 2: Returning Child Properties for Each Item
You can use nested outputs to return specific child properties for the current iteration of the parent output. There are a few scenarios where you might find this helpful:
- When the objects in the list have a lot of data, but you only need a subset of the properties
- When you want to manipulate the data of each child in the list into a different structure.
- When you use an operation with a nested output as the source for a form's dropdown field, the nested keys will be used to provide suggestions for the value and label.
In the example below, the list: body
key-value pair has nested outputs ofid: current.id
, description: current.description
, and url: current.url
.
Updated about 2 months ago