Donation post-upsert 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_Post Label: [MoveData] Donation: Donation - Post Upsert Type: Auto-Launched Flow Template API version: 60.0 Status: Active
This flow handles comprehensive post-processing operations after donation (opportunity) records are created or updated, including campaign member creation, matching gift relationship management, and opportunity contact role processing for soft credits.
Purpose#
The flow performs post-upsert operations that:
- Attempt to clean up opportunity naming conflicts with NPSP triggers
- Create campaign member records for donors with hierarchical status management
- Establish bidirectional matching gift relationships between donations
- Process opportunity contact roles for soft credit attribution across campaign hierarchies
- Support complex fundraising attribution scenarios with fundraiser and team-based campaigns
Salesforce fields#
This flow interacts with the Salesforce Opportunity object and its related fields. Below is a mapping of all fields utilised:
| Field API name | Field type | Purpose in flow |
|---|---|---|
| Id | ID | Primary record identifier |
| Name | Text (120) | Opportunity name cleanup for NPSP |
| npsp__Matching_Gift__c | Lookup to Opportunity | Bidirectional matching gift relationships |
| 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 |
Input variables#
Core donation data#
| Variable | Type | Required | Description |
|---|---|---|---|
Record |
Opportunity SObject | Yes | The Opportunity record that was processed |
DonorContact |
Contact SObject | No | Primary contact associated with the donation |
DonationCampaign |
Campaign SObject | No | Campaign associated with the donation |
Campaign member configuration#
| Variable | Type | Default | Description |
|---|---|---|---|
Config_CreateCampaignMembers |
Boolean | true | Enable campaign member creation |
Config_CampaignMemberDeleteExistingStatuses |
Boolean | false | Remove existing campaign member statuses |
Config_CampaignMemberLabelTeamLeader |
String | "Team Leader" | Label for team leader status |
Config_CampaignMemberLabelFundraiser |
String | "Fundraiser" | Label for fundraiser status |
Config_CampaignMemberLabelRecurringDonor |
String | "Recurring Donor" | Label for recurring donor status |
Config_CampaignMemberLabelDonor |
String | "Donor" | Label for donor status |
Config_CampaignMemberLabelProspect |
String | "Prospect" | Label for prospect status |
Campaign hierarchy structure#
| Variable | Type | Description |
|---|---|---|
Campaign_CampaignRecord |
Campaign SObject | Top-level campaign record |
Campaign_CampaignContact |
Contact SObject | Contact associated with top-level campaign |
Campaign_TeamRecord |
Campaign SObject | Team-level campaign record |
Campaign_TeamContact |
Contact SObject | Contact associated with team campaign |
Campaign_FundraiserRecord |
Campaign SObject | Individual fundraiser campaign record |
Campaign_FundraiserContact |
Contact SObject | Contact associated with fundraiser campaign |
CampaignIdList |
String Collection | List of campaign IDs for member creation |
Soft credit configuration#
| Variable | Type | Default | Description |
|---|---|---|---|
Config_DonationOpportunityContactRoleSoftCredit |
Boolean | true | Enable opportunity contact role soft credits |
Config_DonationSoftCredit_PreventDel |
Boolean | false | Prevent deletion of existing contact roles |
Config_DonationSoftCredit_Role_Donor |
String | "Donor" | Contact role for primary donor |
Config_DonationSoftCredit_Role_Fundraiser |
String | "Soft Credit" | Contact role for fundraiser attribution |
Config_DonationSoftCredit_Role_Team |
String | "Soft Credit" | Contact role for team attribution |
Config_DonationSoftCredit_Role_Campaign |
String | "Soft Credit" | Contact role for campaign attribution |
Advanced soft credit roles#
| Variable | Type | Description |
|---|---|---|
Config_DonationSoftCredit_Role_Fundraiser_CampaignFundraiser |
String | Role when donor has fundraiser campaign |
Config_DonationSoftCredit_Role_Fundraiser_CampaignTeamFundraiser |
String | Role when donor has team+fundraiser campaigns |
Config_DonationSoftCredit_Role_Team_CampaignTeam |
String | Role when donor has team campaign |
Config_DonationSoftCredit_Role_Team_CampaignTeamFundraiser |
String | Role when donor has team+fundraiser campaigns |
Config_DonationSoftCredit_Role_Campaign_CampaignFundraiser |
String | Role when donor has campaign+fundraiser |
Config_DonationSoftCredit_Role_Campaign_CampaignTeam |
String | Role when donor has campaign+team |
Config_DonationSoftCredit_Role_Campaign_CampaignTeamFundraiser |
String | Role when donor has all three levels |
Output variables#
| Variable | Type | Description |
|---|---|---|
Logs |
MoveDataLogEntry[] | Processing logs from all operations |
LogsJSON |
String | JSON representation of processing logs |
Flow logic#
1. NPSP name field cleanup#
Problem resolution: NPSP triggers automatically generate opportunity names based on donor and amount information. When MoveData sets custom names during mapping, this can create conflicts with NPSP's naming logic.
Solution process:
- Detection: Checks if the opportunity record has a Name field that was set during processing
- Field clearing: Uses
ClearFieldFlowComponentto remove the Name field from the record - NPSP integration: Allows NPSP triggers to generate appropriate names post-commit
Technical implementation:
IF Record.Name WasSet THEN
Add "Name" to FieldList
Clear Name field from Record
2. Campaign member management#
Prerequisites validation: The flow validates all required conditions before creating campaign members:
- Campaign exists with valid ID
- Contact exists with valid ID
- Campaign member creation is enabled
Campaign member status initialisation:
InitialiseCampaignMemberComponent Parameters:
- CampaignId: DonationCampaign.Id
- DeleteOtherCampaignMemberStatuses: Config setting
- Status Labels: All configurable member status labels
Hierarchical status management: The flow establishes a prioritised hierarchy:
- Team Leader (highest priority)
- Fundraiser
- Recurring Donor
- Donor (target status for this flow)
- Prospect (lowest priority)
Campaign member creation logic:
- Attempts to assign "Donor" status to the contact
- Respects existing higher-priority statuses (Team Leader, Fundraiser, Recurring Donor)
- Upgrades lower-priority statuses (Prospect)
- Uses
CreateCampaignMemberComponentWithLogsfor detailed logging
3. Matching gift relationship processing#
Matching gift detection: The flow identifies when a donation is part of a matching gift relationship:
IF Record.npsp__Matching_Gift__c WasSet AND
Record.npsp__Matching_Gift__c IsNotNull
Bidirectional relationship establishment:
Step 1 - Retrieve matched donation:
- Queries the matched donation record by ID
- Retrieves current matching gift relationship fields
Step 2 - Validate relationship direction:
- Checks if matched donation already links back to current record
- Prevents circular or duplicate relationship creation
Step 3 - Update matched donation:
- Sets
npsp__Matching_Gift__con matched donation to point to current record - Creates bidirectional matching gift relationship
NPSP matching gift fields:
npsp__Matching_Gift__c: Links to the related donationnpsp__Matching_Gift_Account__c: Employer accountnpsp__Matching_Gift_Employer__c: Employer namenpsp__Matching_Gift_Status__c: Matching gift status
4. Opportunity contact role soft credit processing#
Multi-level campaign attribution: The flow supports complex campaign hierarchies with three levels:
- Top campaign: Overall campaign or cause
- Team campaign: Team or group within the campaign
- Fundraiser campaign: Individual fundraiser within team
Contact role assignment logic: The OppContactRoleSoftCreditFlowComponent processes multiple scenarios:
Scenario 1 - Direct donor:
- Primary donor gets "Donor" role
- Most common scenario for individual donations
Scenario 2 - Single-level attribution:
- Campaign organiser gets "Soft Credit" role
- Team leader gets "Soft Credit" role
- Individual fundraiser gets "Soft Credit" role
Scenario 3 - Multi-level attribution:
- Supports combinations of campaign/team/fundraiser
- Uses specialised role configurations for complex scenarios
- Prevents duplicate role assignments
Role configuration matrix: The flow uses different role labels based on campaign hierarchy complexity:
| Donor campaign level | Assigned contact | Role configuration variable |
|---|---|---|
| Campaign Only | Campaign Contact | Config_DonationSoftCredit_Role_Campaign |
| Team Only | Team Contact | Config_DonationSoftCredit_Role_Team |
| Fundraiser Only | Fundraiser Contact | Config_DonationSoftCredit_Role_Fundraiser |
| Campaign + Team | Both Contacts | Config_DonationSoftCredit_Role_Campaign_CampaignTeam |
| Campaign + Fundraiser | Both Contacts | Config_DonationSoftCredit_Role_Campaign_CampaignFundraiser |
| Team + Fundraiser | Both Contacts | Config_DonationSoftCredit_Role_Team_CampaignTeam |
| All Three Levels | All Contacts | Config_DonationSoftCredit_Role_Campaign_CampaignTeamFundraiser |
Soft credit prevention:
Config_DonationSoftCredit_PreventDel: Prevents deletion of existing contact roles- Preserves manually created contact role assignments
Error handling#
NPSP integration protection#
- Field clearing prevents naming conflicts with NPSP triggers
- Matching gift relationships use NPSP standard fields
- Contact role assignments follow NPSP soft credit patterns
Relationship validation#
- Validates matching gift relationships before creation
- Prevents circular references in matching gifts
- Checks for existing relationships before updates
Campaign member deduplication#
- Uses hierarchical status system to prevent duplicate statuses
- Respects existing higher-priority campaign member statuses
- Provides detailed logging for status assignment decisions
Dependencies#
Apex components#
- movedata__ClearFieldFlowComponent: Field cleanup for NPSP integration
- InitialiseCampaignMemberComponent: Campaign member status setup
- CreateCampaignMemberComponentWithLogs: Campaign member creation with logging
- OppContactRoleSoftCreditFlowComponent: Complex soft credit role processing