Donation mapping flow
Note
This flow is self-documenting and should be viewed within Salesforce (Setup > Process Automations > Flows). This document is to support working through a visual flow. Please note: the flow commentary is produced using AI.
Overview#
Flow name: MoveData_Donation_Donation_Mapping Label: [MoveData] Donation: Donation - Mapping Type: Auto-Launched Flow Template API version: 60.0 Status: Active
This flow handles the comprehensive mapping and transformation of donation data from external platforms into Salesforce NPSP-enabled Opportunity records. It processes donations across multiple statuses including successful payments, refunds, failures, pledges, and matching gift scenarios.
Purpose#
The flow processes incoming donation data and maps it to appropriate Salesforce NPSP fields while handling:
- Multi-status donation processing (success, refund, failed, pledge, offline, static)
- Donor relationship management (Contact/Account assignment including anonymous donations)
- Currency setting and fee calculations with platform fee deduction options
- Recurring donation parent-child relationships
- Matching gift processing and employer attribution
- NPSP Payment record creation for refunds
- Date conversions and close date management
- Fee tracking across multiple fee types (platform, gateway, taxes)
- Dynamic donation naming with configurable patterns
Salesforce fields#
The flow interacts with multiple Salesforce objects and their fields. Below is a comprehensive mapping of all fields utilised:
| Object | Field API name | Field type | Purpose in flow |
|---|---|---|---|
| Opportunity | Id | ID | Primary record identifier |
| Name | Text (120) | Donation name using dynamic patterns | |
| Amount | Currency | Primary donation amount | |
| StageName | Picklist | Status-based stage assignment | |
| Probability | Percent | Stage-based probability setting | |
| CloseDate | Date | Transaction/completion date | |
| Description | Long Text Area | Message/description from donation | |
| AccountId | Lookup to Account | Associated account relationship | |
| RecordTypeId | Lookup to RecordType | "Donation" record type assignment | |
| CampaignId | Lookup to Campaign | Campaign association | |
| IsPrivate | Checkbox | Anonymous donation privacy flag | |
| npsp__Primary_Contact__c | Lookup to Contact | NPSP primary contact relationship | |
| npsp__Matching_Gift__c | Lookup to Opportunity | Link to original matched donation | |
| npsp__Matching_Gift_Account__c | Lookup to Account | Matching gift employer account | |
| npsp__Matching_Gift_Employer__c | Text | Matching gift employer name | |
| npsp__Matching_Gift_Status__c | Picklist | Matching gift processing status | |
| npe03__Recurring_Donation__c | Lookup to Recurring Donation | Parent recurring donation link | |
| movedata__Platform_Key__c | Text | External platform identifier | |
| md_npsp_pack__Fee__c | Currency | Aggregate processing fees | |
| md_npsp_pack__Gateway_Fee__c | Currency | Payment processor charges | |
| md_npsp_pack__Platform_Fee__c | Currency | Fundraising platform charges | |
| md_npsp_pack__Tax__c | Currency | Overall tax amounts | |
| md_npsp_pack__Gateway_Fee_Tax__c | Currency | Tax on gateway charges | |
| md_npsp_pack__Platform_Fee_Tax__c | Currency | Tax on platform charges | |
| md_npsp_pack__Receipt_Number__c | Text (50) | Donation receipt number | |
| Contact | Id | ID | Contact record identifier |
| FirstName | Text (40) | Contact first name for naming | |
| LastName | Text (80) | Contact last name for naming | |
| Name | Formula | Full name for donation naming | |
| AccountId | Lookup to Account | Account relationship resolution | |
| Account | Id | ID | Account record identifier |
| Name | Text | Account name for donation naming | |
| Campaign | Id | ID | Campaign record identifier |
| npe03__Recurring_Donation__c | Id | ID | Recurring donation record identifier |
| npe03__Contact__c | Lookup to Contact | Recurring donation contact | |
| md_npsp_pack__Platform_Key__c | Text (100) | Platform identifier for matching | |
| npe01__OppPayment__c | npe01__Opportunity__c | Master-Detail to Opportunity | Payment-opportunity relationship |
| npe01__Payment_Amount__c | Currency | Refund payment amount | |
| npe01__Payment_Date__c | Date | Refund transaction date | |
| npe01__Paid__c | Checkbox | Payment completion status |
Input variables#
Core donation data#
| Variable | Type | Required | Description |
|---|---|---|---|
Record |
Opportunity SObject | Yes | The Opportunity record being processed |
Amount |
Currency | No | Donation amount before fee calculations |
StartDate |
DateTime | No | Donation/transaction date |
Status |
String | No | External platform status (success/refund/failed/pledge/offline/static) |
Message |
String | No | Donation message/description |
ReceiptNumber |
String | No | External receipt or transaction number |
Anonymous |
Boolean | No | Flag indicating anonymous donation |
Related records#
| Variable | Type | Description |
|---|---|---|
DonorContact |
Contact SObject | Primary contact for the donation |
DonorAccount |
Account SObject | Associated account for the donation |
DonationCampaign |
Campaign SObject | Associated campaign |
RecurringDonation |
npe03__Recurring_Donation__c | Parent recurring donation if applicable |
Platform integration#
| Variable | Type | Description |
|---|---|---|
Platform |
String | Platform identifier |
PlatformKey |
String | Unique platform key for record matching |
ParentKey |
String | Parent recurring donation identifier |
Fee structure#
| Variable | Type | Description |
|---|---|---|
Fee |
Currency | General fee amount |
FeePlatform |
Currency | Platform-specific processing fee |
FeePlatformPublic |
Currency | Public platform fee (tip/donation to platform) |
FeeGateway |
Currency | Payment gateway processing fee |
Tax |
Currency | General tax amount |
TaxPlatform |
Currency | Tax on platform fees |
TaxGateway |
Currency | Tax on gateway fees |
Matching gifts#
| Variable | Type | Description |
|---|---|---|
MatchedContact |
Contact SObject | Contact associated with matching gift |
MatchedAccount |
Account SObject | Employer account for matching gift |
MatchedKey |
String | Platform key for matched donation |
Configuration variables#
| Variable | Type | Default | Description |
|---|---|---|---|
Config_AnonymousContactId |
String | - | ID of anonymous contact record |
Config_DonationAmountSubtractFeePlatform |
Boolean | false | Subtract platform fees from donation amount |
Config_DonationAmountSuppress |
Boolean | false | Skip amount processing entirely |
Config_DonationStageSuppress |
Boolean | false | Skip stage assignment |
Config_DonationSetCloseDate |
Boolean | true | Set close date from start date |
Config_DonationSetDescription |
Boolean | true | Set description from message |
Config_DonationSetAnonymousAsPrivate |
Boolean | true | Mark anonymous donations as private |
Config_IgnoreOfflineDonations |
Boolean | true | Skip processing offline donations |
Config_IgnoreFailedDonations |
Boolean | true | Skip processing failed donations |
Config_DonationNameContact |
String | (ASCII) | Naming pattern for contact-based donations |
Config_DonationNameAccount |
String | (ASCII) | Naming pattern for account-based donations |
Output variables#
| Variable | Type | Description |
|---|---|---|
Record |
Opportunity SObject | Updated opportunity record |
MatchedRecordEntry |
Opportunity SObject | Matched opportunity for matching gifts |
Flow logic#
1. Pre-processing validation#
Refund without original donation check:
- Validates that refund transactions have an existing opportunity to refund against
- Sets error and terminates processing if refund attempted on new record
Anonymous donor resolution:
- Attempts to resolve existing donor from opportunity record
- Falls back to recurring donation contact if available
- Uses configured anonymous contact as final fallback
2. Donor relationship management#
Donor priority resolution:
- Existing donor: Uses contact already on opportunity record
- Recurring donor: Inherits contact from parent recurring donation
- Anonymous donor: Uses configured anonymous contact ID
- Provided donors: Uses DonorContact or DonorAccount from input
Account ID resolution:
- Calls helper subflow to determine appropriate AccountId
- Handles both direct account assignments and contact-derived accounts
3. Recurring donation integration#
Parent relationship processing:
- Generates platform key for parent recurring donation when ParentKey provided
- Looks up existing recurring donation record by platform key
- Sets
npe03__Recurring_Donation__crelationship on opportunity
4. Matching gift processing#
Matching gift detection:
- Processes matched contact or account information
- Sets NPSP matching gift fields:
npsp__Matching_Gift_Employer__c: Employer namenpsp__Matching_Gift_Account__c: Employer accountnpsp__Matching_Gift_Status__c: Set to "Received"
Matched record linking:
- Generates platform key for matched donation
- Links to original donation via
npsp__Matching_Gift__cfield
5. Date and currency processing#
Close date assignment:
- Skip: If
Config_DonationSetCloseDateis false - Start date: Converts StartDate to local date if provided
- Current date: Uses current date as fallback
Currency setting:
- Sets currency code using
SetCurrencyValueFlowComponent - Ensures consistent currency handling across multi-currency orgs
6. Status-based processing#
The flow handles six distinct donation statuses:
Success status#
- Stage: "Closed Won"
- Amount: Calculated amount (with optional fee deduction)
- Probability: 100%
Offline status#
- Configurable skip: Can be skipped via
Config_IgnoreOfflineDonations - Processing: Same as success when not skipped
Refund status#
Validation process:
- Checks refund amount does not exceed original donation amount
- Updates existing payment records with refund amount
- Creates negative NPSP Payment record for refund
- Adjusts opportunity amount by subtracting refund
Full vs partial refunds:
- Partial: Maintains "Closed Won" status
- Full: Changes to "Closed Lost" status
Failed status#
- Configurable skip: Can be skipped via
Config_IgnoreFailedDonations - Stage: "Declined" when processed
- Amount: Set to calculated amount
Pledge status#
- Stage: "Pledged"
- Amount: Set to calculated amount
- Use case: Committed donations not yet collected
Static status#
- Behaviour: Updates existing record amount only
- Use case: Where an amount has changed but there is no supporting detail
7. Amount and fee calculations#
Base amount calculation:
CalculatedAmount = IF(Config_DonationAmountSubtractFeePlatform, Amount - CalculatedFeePlatform, Amount)
Fee hierarchy:
- Platform fee: FeePlatformPublic -> FeePlatform (fallback)
- Fee fields set: Fee, FeePlatform, FeeGateway with respective taxes
8. NPSP payment integration#
Refund payment creation:
- Creates
npe01__OppPayment__crecord for refunds - Sets negative payment amount
- Links to parent opportunity
- Uses refund transaction date
9. Privacy and anonymity#
Anonymous donation handling:
- Sets
IsPrivate = truewhen Anonymous flag is set - Respects
Config_DonationSetAnonymousAsPrivateconfiguration - Maintains donor privacy in public donation listings
10. Dynamic naming#
Naming pattern processing:
- Contact-based: Uses
Config_DonationNameContactpattern - Account-based: Uses
Config_DonationNameAccountpattern - Fallback: ASCII-encoded default patterns
- Pattern parser: Supports field merge syntax like
{!Contact.Name}
Default patterns:
- Contact:
{!Contact.Name} {!Amount} {!RecordType.Name} {!CloseDate} - Account:
{!Account.Name} {!Amount} {!RecordType.Name} {!CloseDate}
11. Record type and final assembly#
Record type assignment:
- Retrieves "Donation" record type ID via
GetRecordTypeComponent - Sets RecordTypeId on opportunity
Final field assignment:
- Campaign association
- Receipt number
- Platform key for future matching
- Description from message (if configured)
Error handling#
Comprehensive error tracking#
Error categories:
- Missing opportunity for refund processing
- Refund amount exceeding original donation
- Currency conflicts
- Invalid donor configurations
Detailed logging:
- Refund calculation details
- Skipped donation reasoning
- Fee calculation breakdowns
- Processing decision points
Dependencies#
Apex components#
- SetCurrencyValueFlowComponent: Currency management
- ConvertToLocalDateFlowComponent: Date timezone conversion
- movedata__GetRecordTypeComponent: Record type resolution
- movedata__NamePatternParserComponent: Dynamic name generation
- movedata__WriteToLogFlowComponent: Comprehensive logging
Subflows#
- MoveData_Donation_Donation_Key: Platform key generation
- MoveData_Donation_Recurring_Key: Recurring donation key generation
- MoveData_Donation_Helper_Get_Account_ID: Account resolution logic