Skip to content

Instantly share code, notes, and snippets.

@acrosman
Last active December 6, 2022 03:32
Show Gist options
  • Save acrosman/b925ab626c6281144689f3c1de76dda2 to your computer and use it in GitHub Desktop.
Save acrosman/b925ab626c6281144689f3c1de76dda2 to your computer and use it in GitHub Desktop.
Snowfakery NPSP Basic Recipe
# Snowfakery Recipe to generate data for a specific project that uses NPSP.
# This recipe will generate 30 accounts with gifts using NPSP standard patterns. Yes, you can make the 30 a parameter,
# but the goal here is simple for first time users. Gift yourself homework of making that a variable. This recipe also
# assumes that you need payment records but are not automatically generating those in NPSP settings.
# Load the NPSP macros (which in turn load marcos for SF Standard objects).
- include_file: npsp_macros.yml
# Create an Account using the SF Standard Object macro loaded in the previous line.
- object: Account
include: SFStandardAccount # This is what generates the Account object itself from that macro.
count: <<30 * 0.20>> # 20% of the Accounts are for Companies
fields:
RecordType: Organization
friends: # Create the gift to from this new company.
- object: Opportunity
include: SFStandardOpportunity
fields:
Name: Opportunity relating to <<Account.Name>>
AccountId:
reference: Account
# This is a custom field. Either remove this or add the field to get to work for your org. It's here as an example.
Ready_to_Post__c: True
CampaignId: # This recipe assumes that the campaigns the associate with the gift already exist and you just want them randomly assigned.
random_choice: # don't get too exicited by these values, they are copy pasted from a Trailhead org.
- 701f40000012C7zAAE
- 701f40000012C7xAAE
- 701f40000012C7yAAE
friends: # Create the payment for the gift.
- object: npe01__OppPayment__c
include: Standard npe01__OppPayment__c
fields:
npe01__Opportunity__c:
reference: Opportunity
npe01__Payment_Amount__c: <<Opportunity.Amount>> # Notice we're pulling in the gift amount here. You could also do multiple payments and split the amounts.
# The 80% of the gifts will come from Households.
- object: Account
include: SFStandardAccount
count: <<30 * 0.80>>
fields:
Name: <<fake.last_name>> Household # Corrected to match household naming convention.
RecordType: HH_Account
friends:
- object: Contact # Add the contact to the household.
include: SFStandardContact
count: 1 # These are one person households, but you could add another person here.
fields: # Here we're tweaking some details that cam from the macro that aren't what we want.
Title: None
AccountId:
reference: Account
- object: Opportunity # Add the household's gift. From here on, the is the same as above (but doesn't need to be).
include: SFStandardOpportunity
fields:
Name: Opportunity relating to <<Account.Name>>
AccountId:
reference: Account
Ready_to_Post__c: True
CampaignId:
random_choice:
- 701f40000012C7zAAE
- 701f40000012C7xAAE
- 701f40000012C7yAAE
friends:
- object: npe01__OppPayment__c
include: Standard npe01__OppPayment__c
fields:
npe01__Opportunity__c:
reference: Opportunity
npe01__Payment_Amount__c: <<Opportunity.Amount>>
# This macro file provides shortcuts to centralize some of the more complex
# objects and repeative tasks. It is focused on Objects from the NPSP package.
# Standard Salesforce Objects are generated with macros in a file dedicated to
# them.
- include_file: sf_standard_macros.yml # Loads the standard object macros.
# A macro is a lot like any other object definition.
- macro: Standard npsp__General_Accounting_Unit__c
fields:
Name: <<fake.word>> Sponsorship # This macro treats the GAUs as a label, but you can add more fields if you need more careful processing.
- macro: Standard npe01__OppPayment__c
fields:
npe01__Payment_Date__c: # We are making all the payments in the last week. You'll see this date range a bunch in this file.
date_between:
start_date: -7d
end_date: today
# This will also evaluate to true given the payment dates, but I left it to show how you can do calculations based on generated field values.
npe01__Paid__c: <<False if this.npe01__Payment_Date__c > today else True>>
npsp__Payment_Acknowledgment_Status__c: # This be dependent on Paid
random_choice:
- To Be Acknowledged
- Acknowledged
- Do Not Acknowledge
npsp__Payment_Acknowledged_Date__c:
date_between:
start_date: <<this.npe01__Payment_Date__c>>
end_date: today
npe01__Check_Reference_Number__c:
random_number:
min: 1000000
max: 10000000
npe01__Payment_Method__c:
random_choice:
- Cash
- Cheque
- Credit Card
npe01__Scheduled_Date__c:
date_between:
start_date: -7d
end_date: +7d
# This set of macros provides a small collection of Salesforce Standard Objects.
# The marcros and recipes that get these objects can override their fields, but
# having these helps ensure you have all the needed required/basic fields while
# being able to focus on the details of your recipe when they are important.
- macro: SFStandardAccount
fields:
Name:
fake: company
BillingStreet:
fake: street_address
BillingCity:
fake: city
BillingState:
fake: state
BillingPostalCode:
fake: postalcode
BillingCountry: United States
ShippingStreet:
fake: street_address
ShippingCity:
fake: city
ShippingState:
fake: state
ShippingPostalCode:
fake: postalcode
ShippingCountry: United States
Phone:
fake: phone_number
Fax:
fake: phone_number
- macro: SFStandardOpportunity
fields:
Name: <<fake.word>> Opportunity
CloseDate:
date_between:
start_date: -30d
end_date: +180d
Amount:
random_number:
min: 50
max: 2000
StageName:
random_choice:
- choice:
probability: 90%
pick: Closed Won
- choice:
probability: 5%
pick: In Progress
- choice:
probability: 5%
pick: New
- macro: SFStandardContact
fields:
Salutation:
fake: prefix
FirstName:
fake: first_name
LastName:
fake: last_name
Email:
fake: email
Phone:
fake: phone_number
MobilePhone:
fake: phone_number
Title:
fake: job
Birthdate:
fake.date_between:
start_date: -50y
end_date: -20y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment