Scripting in Email
Scripting in email is distinct from scripting on forms and items. Email scripts do not fire when a transaction is submitted — they fire when an Email Instance is generated from an Email Definition.
When Email Scripts Run
For each email that DonorPoint sends, it generates an individual Email Instance from the Email Definition template. The script runs once per generated instance — once per recipient for mass emails, or once per transaction for autoresponders.
This means the same script runs for every person receiving a given email, with that specific person’s context in scope. The script can:
- Modify the email content dynamically for this recipient
- Suppress sending to this recipient based on a condition
- Trigger side effects (update a record, call an external service) as part of email delivery
Email Script Context
The variables available depend on which type of email is being generated:
Receipt Email (Transaction Autoresponder)
| Variable | Contents |
|---|---|
contact |
The recipient’s Contact record |
account |
The DonorPoint account |
campaign |
The form this transaction came from |
purchaseOrder |
The transaction being receipted |
orderItems |
All line items in the transaction |
Mass Email (Email Solicitation)
| Variable | Contents |
|---|---|
contact |
The individual recipient’s Contact record |
account |
The DonorPoint account |
emailSolicitation |
The mass email job record |
emailDefinition |
The email template being rendered |
Recurring Payment Email
| Variable | Contents |
|---|---|
contact |
The donor’s Contact record |
account |
The DonorPoint account |
recurringDonationInstance |
The recurring schedule |
purchaseOrder |
The most recent payment transaction |
Important Difference from Form Scripts
Form post-processing scripts run once per transaction — all items in the transaction are in context simultaneously.
Email scripts run once per email instance — they are scoped to a single recipient and their specific context. If a mass email is sent to 5,000 contacts, the script runs 5,000 times, each time with a different contact in scope.
→ Full context reference: Scripting Contexts
→ Scripting language and services: Scripting Guide