Getting started

This tutorial explains how to create an action type that is backed by an Ontology Edit Function.

Prerequisites

In this tutorial, we will use the same Demo Ticket object type and sample objects as in the Getting Started with Actions tutorial.

Start by writing an Ontology Edit Function that performs the desired edits for your Action. This requires:

  • Setting up a repository using the Functions on Objects TypeScript template,
  • Importing the relevant object types into your repository, and
  • Publishing the Ontology Edit Function for Actions to read.

Information on these steps can be found in the Functions documentation:

  • Getting Started—follow this tutorial to create a basic Functions repository and publish a function
  • Functions on Objects—follow this tutorial to create a Function that uses object data
  • Ontology edits—use this reference to create an Ontology Edit Function

Once you have written and published an Ontology Edit Function, the steps below will connect the function to an Action so that the function can be used to make edits to objects. For the purposes of this tutorial, we have written and published the following Ontology Edit Function from a repository:

Ontology Edit Function

For convenience, the code is available here:

Copied!
1 2 3 4 5 @OntologyEditFunction() public addPriorityToTitle(ticket: DemoTicket): void { let newTitle: string = "[" + ticket.ticketPriority + "]" + ticket.ticketTitle; ticket.ticketTitle = newTitle; }

Functions for use in Action types must be annotated with @OntologyEditFunction() instead of @Function(). Further details can be found in the documentation for functions on objects.

Creating a Function backed action

In the Rules section, add a single rule of type Function. Search for the function you published as part of the prerequisites, and pick the latest version. Configure the inputs to match up to the Action parameters, as below. Note that a Function Rule cannot be combined with other rules.

Configure Inputs

When selecting the Function, all inputs of the Function will automatically be created as Parameters and added to the Forms tab. In the example shown in these screenshots, a Demo Ticket parameter of type Object reference has been created. The parameter can now be customized further if needed.

Demo Ticket

Demo Ticket Details

Save your Action and configure it across the platform as described in the guidance for integration with other applications.

Changing Function logic

If the Ontology Edit Function logic is changed, the Action does not automatically update to match it. Instead, you must return to the Rules section of the Action and upgrade the version of the Function that the Action is referencing. For example, if we published 0.1.2 of our Function, we would need to update it here:

Update Function Logic