Script Types
Triggers
Triggers can be setup to run before and/or after creation, update, and deletion of object instances, as well as before and after session authentications (to allow for custom authentication mechanisms).
Before Trigger
All before
triggers are run inline, that is they return false or throw an error from the script to cancel the operation. In object instance before
triggers, changes can be made inline to instance properties directly from the script, and made as either the script's calling principal or given a grant. These changes are recorded in the audit logs as separate events.
All before update
trigger code should be idempotent - they should return the same result after every operation - as they may run more than once during update conflict resolution events.
After Trigger
An after
script runs after the operation that triggered it has completed and is ideally suited for sending notifications. These triggers are guaranteed to run only once.
Routes
A route script creates new API endpoints for an organization. Route matching is available using wildcards, named-parameters and regular expression matching. A route can be set to run as the calling principal or as any other available org principal. ACL can also be applied at the configuration level in order to restrict endpoint access to a set of roles or specific accounts.
PUT and POST routes can be configured to parse application/x-www-form-urlencoded form data, as well as accept text/ content-types. When accepting text/ content, the request body will be in raw form. Otherwise, application/json and application/x-www-form-urlencoded are parsed into json objects.
Jobs
Jobs are scheduled using standard cron syntax and are suited for maintenance tasks, statistics gathering and data post-processing.
Libraries
A library is a CommonJS library that can be loaded by triggers, jobs, routes, and other library scripts. The format follows that of a common js module. A library is configured with an Export
property, the name that will be used to import into other scripts. The name follows the same c_
naming convention as the rest of the api.
For example, a library script with the Export
name of c_utils
could look like the following:
IMAGE HERE
With the following script:
And could then be imported into other scripts like the following
Last updated