This tutorial explains how to create an action type that is backed by an Ontology Edit Function.
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:
Information on these steps can be found in the Functions documentation:
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:
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.
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 ontology rules.
When selecting the Function, all inputs of the Function will automatically be created as Parameters and added to the Parameters 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.
Save your Action and configure it across the platform as described in the guidance for integration with other applications.
By default, if the 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 version 0.1.2 of the Function, we would need to update it here:
You can optionally choose to enable auto upgrades for the Function that the Action is referencing. If enabled, the Action will depend on the Function at a version range and resolve the version at runtime.
To enable auto upgrades for an Action, navigate to the Rules section of the Action and select the Function parameter. In the Function dropdown, select the minimum version of the Function that you want to be run and enable the Auto upgrade option. This will correspond to a version range dependency that comprises all backward compatible versions, such as minor or patch upgrades, of the selected minimum version.
Auto upgrades are disabled for Function versions of the form 0.y.z
. These versions are reserved for initial development where Function API and behavior may change frequently and should not be considered stable. Refer to the documentation on choosing a release version.
If auto upgrades are enabled for a Function-backed Action, users who do not have edit permissions on the Action can modify the Action's behavior by making changes to the backing Function. This is because edit permissions on the Function are not tied to the permissions on the Action.
Auto upgrades can result in Action execution failures due to breaking changes in bad Function releases.
The provenance of the Action is set according to the provenance of the selected minimum Function version. If a newer release of the Function returns edits outside of this provenance (for example, an additional Object type), Action execution will fail.
Currently, the provenance consists only of the Object types that the Action may edit at runtime.