Scripting on Donations
Donation items use the standard Item scripting hooks. The post-processing hook is particularly important for donations because it fires after the financial record is committed — making it the right place for matching gift checks, major gift notifications, and GL posting.
For the full scripting context reference, see Scripting Contexts.
Post-Processing Script on Donation Items
When it runs: After the donation transaction is saved.
What it can do:
- Check whether this donor’s employer offers matching gifts and trigger an outreach
- Notify a major gift officer when a gift exceeds a threshold
- Post the donation to an external GL or accounting system
- Update the donor’s lifetime giving total in an external CRM
- Create a pledge follow-up task if the gift was below a cultivation threshold
Example — major gift notification:
import "mailer";
if (orderItem.extendedPrice >= 500) {
mailer.sendEmail(
account.getProperty('majorGiftsOfficerEmail'),
'Gift above threshold from ' + contact.firstName + ' ' + contact.lastName,
'Amount: $' + orderItem.extendedPrice + ', Fund: ' + orderItem.fund.name
);
}
Pre-Processing Script on Donation Items
Use the pre-processing hook to set a default fund designation from the donor’s giving history, or to apply a campaign-specific default designation when the item is selected.
Fund Custom Fields in Scripts
Fund custom fields are available on the orderItem.fund object:
// GL account code
var glCode = orderItem.fund.get('GL_ACCOUNT').value;
// Agency external identifier
var agencyId = orderItem.fund.get('AgencyCode').value;
See Customization on Funds for the custom fields you can define on funds, and Scripting Guide for the full reference.