Automation and Integration using Scripting
DonorPoint enables comprehensive configuration of content and transactions, plus rich features to integrate with external systems via Automation and Integration using Scripting.
The Integration menu on the DonorPoint sidebar contains the definitions of Automation and Integrations. These DonorPoint entities store script in Script Module entities, which makes those scripts reusable and easier to maintain across multiple uses.
Event Handlers
Event Handlers are Scripts that are run when a entity is created, loaded, inserted or updated. An EventHandler has the type of event on which to be called, whether the Event Handler is active or not, and the Script Module to run when the event is triggered. Event types are named for the DonorPoint classes with the following prefixes:
- onCreate: when a new entity of the class is created
- onLoad: when an entity of the class is loaded from the database for viewing
- onInsert: when a new entity of the class is saved to the database
- onUpdate: when an existing entity of the class is updated in the database
For example, the class of Forms in DonorPoint is named ‘Campaign’ (for historical reasons). The event types to listen for events on transactions are:
- onCreateCampaign
- onLoadCampaign
- onInsertCampaign
- onUpdateCampaign
When the Script Module is called for any of these events, the current entity is injected as a variable named ‘this’ and the currrent EntityHome object is injected by name, beginning with a lower case (e.g. ‘campaignHome’).
Script and Workflows in Form-based Transactions
Forms and Orderable Items have a property named ‘Init Script Module’. For forms this script is executed when the form is viewed. For Orderable Items this script is executed when an Order Item corresponding to that Orderable Item is added to a form.
When the Script Module is called for any of these events, the current transaction or order item is injected as a variable named ‘this’.
Workflows are lists of tasks which run when tranasctions are created from donor-facing forms. When a transaction on a form suceeds, any workflow defined on the form and any workflows defined on any items on the form are executed.
Workflows can have conditions specified on them to control when they are executed, for example when a transaction value is above a certain amount.
Workflows can include several types of actions:
- Email: send an email to one or more recipients, optionally from a template
- Script: execute a script
Note that when the Script actions are called, the current transaction or order item is injected as a variable named ‘this’.
Specific Scripts on Emails, Documents, etc.
Similar initialization features appear on other DonorPoint items, as Javascript content as properties on the entities (not reusable script as in the case of Event Handlers, Workflows, etc.).
- Creation Scripts are run when new Teams are created or Members join Community campaigns.
- Email Messages run Creation Script when each instance of an email is sent.
- Pages, Reports and Dashboards run Creation Script before being rendered.
- Document Templates run Creation Script when instances are generated.
- Creation Script is run when entities are generated from Campaign Templates.
- Creation Script is run when new Accounts sign up in DonorPoint.
Scheduled Jobs
Scheduled Jobs are Scripts which are run on a scheduled basis at 5AM Eastern time. Scheduled Jobs are defined by a nightly schedule (daily, semi-weekly, weekly, monthly, etc.), and by the User Account to run the script as.
Webhooks
Webhooks are Scripts that can be run externally via an HTTP POST request to DonorPoint. A Webhook is defined
The Webhook URL can be found on the view page for the Webhook.
Requests to Webhooks must be authenticated via Bearer tokens. A Bearer token can be obtained from the webhook:
https://test.gobigriver.com/api/v2/userauthentication/auth
where the value of the request header ‘BRAPITOKEN’ set to a valid API Key on your Account (found on the Integration tab on Manage My Account in DonorPoint). The bearer token is returned in the ‘token’ property of the response object, and can be used in Webhook POSTs by passing it as the value of the BRAPITOKEN header.
The body of the HTTP POST request is injected as the variable ‘requestBody’. No user will be defined, but your Account will be injected with the name ‘account’, from which you can look up a user.
The Script Module in a Webhook is expected to return a string variable if it is expected to return one to the calling program. Standard JSON class methods are available in the Script to marshall and unmarshall objects from strings.
REST API
Entities in DonorPoint can be accessed via RESTful endpoints. Contact support for more information.