Salesforce scratch orgs makes it very easy to track metadata changes. But if you are developing an app that involves non profit starter pack,
it is usually tricky to setup a scratch org with NPSP packages.
In this blog, we will go through different steps needed to setup a scratch org with NPSP packages.
NPSP is basically a combination of multiple appexchange packages. But to install these your sandbox/scratch org needs to meet certain conditions.
These prerequisites are adding certain recordtypes to Account and Opprotunity and adding an Opprotunity sales process.
Metdata needed for these can be found in the link -
https://github.com/SalesforceFoundation/NPSP/tree/master/unpackaged/pre.
If you wish to run below bash script directly,
you need to copy individual metadata files from above NPSP github repo into a single
npsp-dependencies
folder in deployable format with a combinted package.xml file.
Use cases
- Easy development of enhancements to NPSP in scratch orgs
- Other approaches like using Cumulus CI are usually more time consuming and difficult to setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Make sure that you have set an org as default dev hub. Usually your production environment will be your devhub environment. | |
#sfdx force:config:set defaultdevhubusername=productionUsernameHere | |
echo "Creating scratch org" | |
sfdx force:org:create -s -f config/project-scratch-def.json -a myScratchOrg -d 30 | |
sfdx force:org:open | |
# Before running below line, copy content from inner folders in the github location - | |
# https://github.com/SalesforceFoundation/NPSP/tree/master/unpackaged/pre | |
# and create a single folder "npsp-dependencies" with account, opportunity object files and a combined package.xml | |
echo "Deploying pre dependency for NPSP packages" | |
sfdx force:mdapi:deploy -w 100 -d ./npsp-dependencies -u myScratchOrg | |
echo "(1/6) NPSP Installing Contacts & Organizations 3.7.05" | |
echo "y" | sfdx force:package:install -p 04t80000000gYcfAAE -w 15 -u myScratchOrg | |
echo "(2/6) NPSP Installing Household 3.9.0.8" | |
echo "y" | sfdx force:package:install -p 04t80000000jYrOAAU -w 15 -u myScratchOrg | |
echo "(3/6) NPSP Installing Affiliations 3.6.0.5" | |
echo "y" | sfdx force:package:install -p 04t80000001AVBMAA4 -w 15 -u myScratchOrg | |
echo "(4/6) NPSP Installing Relationships 3.6.0.5" | |
echo "y" | sfdx force:package:install -p 04t80000000tpCGAAY -w 15 -u myScratchOrg | |
echo "(5/6) NPSP Installing Recurring Donations 3.10.0.4" | |
echo "y" | sfdx force:package:install -p 04t80000000tpCBAAY -w 15 -u myScratchOrg | |
echo "(6/6) NPSP Installing Nonprofit Success Pack 3.116.0.5" | |
echo "y" | sfdx force:package:install -p 04t1Y000001I8yUQAS -w 15 -u myScratchOrg | |
echo "if any installation failed, retry it by running corresponding command." | |
echo "pushing package code" | |
sfdx force:source:push -f |
Explanation
Above shell script will work for Mac and Linux users only. If you are a windows user, you might need to copy-paste and run individual commands separately from windows command line.
As part of this script we are first creating a scratch org.
Then we open the scratch org in browser.
After that at line 14 we install all the prerequisites for NPSP package.
Then we install 6 NPSP appexchange packages one after another.
Please note that in future Salesforce might upgrade these packages and the package IDs will change.
In that case find package ID corresponding to the upgraded version and change in the script.
How to use
Make sure that you are inside an sfdx project folder. If not, create a SFDX project using vscode or SFDX cli
Since it is installing 6 different appexchange packages as part of NPSP, the whole process might take some time. You can see the progress.
sfdx force:project:create -n projectName
.
As first step, make sure that you have copied all dependencies from https://github.com/SalesforceFoundation/NPSP/tree/master/unpackaged/pre
to a folder with name npsp-dependencies inside your repository.
Make sure you have set a devhub environment as default that you can use for spinning off scratch orgs( sfdx force:config:set defaultdevhubusername=productionUsernameHere
).
Copy above code into a shell script file. *Example createScratchOrg.sh)
Make sure that your shell script file has proper permissions by running chmod u+x createScratchOrg.sh
.
Finally run the shell script from terminal using ./createScratchOrg.sh
.Since it is installing 6 different appexchange packages as part of NPSP, the whole process might take some time. You can see the progress.
Nice and good article
ReplyDeleteSalesforce CPQ Training
Salesforce CPQ Online Training
https://forums.bestbuy.com/t5/BestBuy-com/Most-Authentic-Databricks-Certified-Associate-Developer-for/m-p/1396462#M112141
ReplyDeleteThanks, admin, for sharing such incredible content on this topic. Now I have got everything I need about it. Here’s another informative piece of content Salesforce for Nonprofits , you may find here more information.
ReplyDelete