Salesforce CPQ - Cancel and Replace
Documentation Link: https://salesforce.quip.com/KXBRArvmUQcG
OVERVIEW
One of the most common scenarios not supported directly with amendments is the ability to combine multiple contracts onto into a single contract and EXTEND that contract beyond the original term. From a functionality perspective, this is known as Cancel & Replace, as the original contracts are cancelled with negative orders and a new quote is created for the customer going forward.
The Cancel & Replace framework is designed to provide a pattern for advanced contract manipulation via customization. While you may choose to install the managed package from the app exchange, the full codebase will be released as open source software available on Github.
- Install Prettier VSCode extension
- Install VSCode ESLint extension
- Install Apex PMD ESLint extension
- In the root directory, run npm install to install necessary packages.
- Add these attributes to your vscode workspace settings (.vscode/settings.json)
{
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"eslint.format.enable": true,
"eslint.lintTask.enable": true,
"apexPMD.rulesets": ["pmd/pmd_rules.xml"],
}
-
merge/rebase from
managed-integration
-
from project root run
./setup.sh orgname [duration]
- this command automates many of the manual steps detailed below.
- the setup.sh script performs the following:
// create project sfdx force:org:create -s -f config/project-scratch-def.json -a $alias -d $duration; // set cli alias sfdx force:config:set defaultusername=$alias // install cpq sfdx force:package:install -r -p $packageversion -w 30 -u $alias -s AllUsers // push local source sfdx force:source:push -f // create test user sfdx force:user:create --setalias cpq-user --definitionfile config/cpquser.json // cli user perms sfdx force:user:permset:assign --permsetname $permset
-
Post Install, you must Authorize new calculation service.
- this step requires logging and performing the following step: Setup > Installed Packages > Salesforce CPQ Configure > Pricing and Calculation > Click Authorize new calculation service
- if you receive an error at this step, the CPQ remote site settings did not get activated during package install. Go to Setup > Remote Site Settings and activate all of them.
-
Data seeding automation Run these scripts from your command line one at a time letting them finish before you run the next.
- you must go to Apex Jobs in Setup to monitor the progress of each of these jobs and only start the next job when the prior one has finished.
sfdx force:apex:execute -f force-app/main/unpackaged/anon-apex/loadQuotes.apex sfdx force:apex:execute -f force-app/main/unpackaged/anon-apex/placeOrders.apex sfdx force:apex:execute -f force-app/main/unpackaged/anon-apex/activateOrders.apex sfdx force:apex:execute -f force-app/main/unpackaged/anon-apex/contractQuotes.apex sfdx force:apex:execute -f force-app/main/unpackaged/anon-apex/activateContracts.apex
- you must go to Apex Jobs in Setup to monitor the progress of each of these jobs and only start the next job when the prior one has finished.
- merge/rebase from managed-integration to your dev branch
- pull your dev branch (remote -> local)
- create your DE Scratch Org (SO)
- install CPQ Package (see below)
- sfdx force:source:push your local workspace to scratch org (project contains project permset Salesforce_CPQ_Cancel_and_Replace that admin user needs)
- Assign permset to cli Admin User
- Post Install Config Setup
sfdx force:org:create -a orgalias-name -f config/project-scratch-def.json -s
SBQQ 226.3 - Summer 20
sfdx force:package:install -p "04t4N000000YTOgQAO"
- Post Install, you must Authorize new calculation service. This step requires logging and performing the following step: Setup > Installed Packages > Salesforce CPQ Configure > Pricing and Calculation > Click Authorize new calculation service**
sfdx force:source:push -f
Assign the following permission sets to your default org User.
sfdx force:user:permset:assign --permsetname Salesforce_CPQ_Cancel_and_Replace
sfdx force:user:permset:assign --permsetname SBQQ__SteelBrickCPQAdmin
sfdx force:user:permset:assign --permsetname SBQQ__SteelBrickCPQUser
Create demo/test User with this project and CPQ permsets pre-configured.
sfdx force:user:create --setalias cpq-user --definitionfile config/cpquser.json
- assign your Scrath Org User to the CPQ Dev Profile
- assing your Scrath Org User to the Salesforce_CPQ_Cancel_and_Replace, SBQQ__SteelBrickCPQAdmin, SBQQ__SteelBrickCPQUser permission sets
-
Create 1 Account. SBQQ__RenewalModel__c = 'Contract Based'
-
Create 1 Product. IsActive=TRUE, SBQQ__QuantityEditable__c=TRUE, SBQQ__SubscriptionPricing__c='Fixed Price', SBQQ__SubscriptionTerm__c='1'
-
Add the Product you just created to the Standard Pricebook and give it a Standard Price.
-
Create an Opportunity.
-
Set Opportunity Pricebook to Standard
-
Add Product to Opportunity as an Opportunity Line Item
-
Create SBQQ__Quote__c record with lookups set to Account, Opportunity, Pricebook Primary=TRUE, Start Date != null, Subscription Terms = 36
-
Create Order by setting SBQQ__Quote__c.SBQQ__Ordered__c=TRUE.
-
Create Contract by setting Opportunity.SBQQ__Contracted=TRUE. if you have done this correctly so far, you should see a Subscription child record looking up to your Contract
-
Click "Activate" button on Contract record.
-
from Quote record, set the Master Contract lookup to the Contract you just created.
This is the minimum starting data setup required to apply the Amend and Replace business rules*