Use Functions in the platform

This section documents various ways that you can use Functions throughout the Foundry platform. This list is kept mostly up to date, but there may be additional ways to use Functions that are not captured here.

Workshop

Workshop supports integration with Functions in a variety of ways, enabling the use of custom logic throughout modules built in Workshop.

Variables

Most Workshop Variables can be Function-backed, allowing an application builder to use Functions to compute values that can then be used throughout Workshop. By default, the value for a variable is recomputed when another variable it depends on is updated. This enables flexible recomputation of values in response to user feedback—for example, when a user edits an input component, a dependent Function-backed Object Set variable will be recomputed automatically.

To learn more, take a look at the tutorial on how to use Functions to back Workshop variables.

Below is the mapping between Workshop variable types and their equivalents in TypeScript. A Workshop variable of each given type can be backed by a Function that returns one of the valid types listed. Learn more about the available Function types are documented.

  • Boolean: boolean
  • String: string
  • Numeric: Integer, Long, Float, Double
  • Date: LocalDate
  • Timestamp: Timestamp
  • Array: BaseType[] or Set<BaseType>
  • Object Set: ObjectSet<ObjectType> (recommended), ObjectType[], or Set<ObjectType>

Object Table: Derived properties

Workshop’s Object Table widget can be configured to compute a Function-backed column, which can update based on user input and will be recomputed on the fly as end users scroll through the table. You can see a full tutorial for using this functionality.

Chart: Derived aggregations

Workshop’s Chart: XY widget supports using a Function-backed aggregation to derive aggregated values on demand. This can be useful if you want to have aggregation data be based on user selection. To use Functions in a Chart widget, simply click to configure a chart layer and select Function aggregation.

use-functions-chart

A reference for the Aggregation API is available. For more advanced use cases, you may want to read the documentation about how to compute custom aggregations.

Actions

Action types enable applications to make changes to the objects in the Foundry ontology and to dispatch external notifications and side effects in a way that is flexible and secure. Within Actions, Functions provide complete flexibility, enabling code authors to define how objects should be updated or how side effects should be configured.

Function-backed Actions

Function-backed Actions use the Ontology edits API to define the logic for how objects should be updated. This allows you to express complex edits in code—for example, updating every objected linked to some starting object. See a tutorial for how to use Function-backed Actions end-to-end.

Side effects: Notifications

An Action can be configured to send a Notification to a specified user. You can use Functions to compute which users should receive a Notification, as well as the contents of the Notification itself. This provides flexibility such as loading recipient user IDs that are stored within objects, or rendering email content based on object data. To learn more, consult the full documentation about Notifications and a guide for how to use Functions to configure Notifications.

Side effects: Webhooks

An Action can also be configured to trigger a Webhook when it is applied. Webhooks enable integration of Foundry with other systems, enabling user-applied Actions to write back to APIs outside of Foundry. You can use Functions to compute the parameters that should be sent to the Webhook that will be executed, enabling workflows like populating Webhook parameters based on object data. View full documentation about Webhooks.

Slate

Slate includes native support for finding and using Functions within the Platform tab. When editing a Slate document, open the Platform tab and add a Foundry Function in the bottom-left. Now, you can search for a Function, configure parameters, and use the result in your Slate document.

use-functions-slate

Note that for historical reasons, the Slate product has its own notion of "Functions", which are snippets of JavaScript logic located within each Slate document. This is why the Functions product is called "Foundry Functions" and is located under the Platform tab. Slate's Functions capability allows for quick, easy data manipulation within a document, but do not have native support for objects.

You can use Slate's Functions and Foundry Functions in combination with each other—for example, you could return data from a Foundry Function and manipulate it in a Slate Function, or use a Slate Function to compute parameters that should be passed into a Foundry Function.

Quiver

Object set plots in Quiver use the same underlying component as Workshop’s Chart: XY widget. As such, you can use Function-backed Aggregations in Quiver analyses as well.