Wednesday 21 February 2018

Scratch Org and installing CPQ package

Scratch Orgs in salesforce is a disposable salesforce environment, it means it's a fresh salesforce env with an expiry date on it, so many configuration can be set in the Salesforce ScratchOrg definition file like if you want multi currency is enabled or not ,....

If you want to know the capabilities please refer to Salesforce DX developer guide as it explains in detail

I've found it interesting as I like working with commands and script to maintain my development environment  better!

Recently I started learning about CPQ and wanted to see if I can create a scratch org and then install the CPQ package on it.

Prepare the environment:

If you have't create a scratch Org first you need to download and install the Salesforce CLI.
Then you need to enable Dev Hub, Go to setup and look for "Dev Hub" and enable it.
\
Go to command prompt and type sfdx without anything else and see if it recognise it.


Create the first Scratch Org

Go to command prompt and type the following command

  • />sfdx force:auth:web:login --setdefaultdevhubusername

Once you login to your org then it save your credential info(user/.sfdx folder)

  • Create a Scratch Org definition file with the following data and save it with a name(mysctrachorg.json)

{
  "orgName": "Cool org",

  "country": "AU",

  "edition": "Enterprise",

  "features": "MultiCurrency;AuthorApex",

  "orgPreferences": {

    "enabled": ["S1DesktopEnabled", "ChatterEnabled"],

    "disabled": ["SelfSetPasswordInApi"]
  }
}

go to command prompt again
  • >sfdx force:org:create -f mysctrachorg.json

After couple of seconds you should see the similar message as bellow
Successfully created scratch org: orgId like 0HF.... , username: test-lkjflkds5@example.com

Now you can open your org just by typing the following command
>sfdx force:org:open --targetusername test-lkjflkds5@example.com

Now since your org is ready go ahead and install the CPQ package

/>sfdx force:package:install -i 04tA0000000WZvmIAG


the open your org and go to setup -> install package and you should able to see the CPQ package in the list





Setting Global username in SFDX

If you are trying to install a package on an org and you get the following error
No defaultusername org found.

Then set the global username that sfdx used , this user should be link to at least one of your scratchorg, this is a example command

>sfdx force:config:set defaultusername=test-lkjflkds5@example.com --global


4 comments:

  1. Nice Blog, Thanks for sharing amazing information with us salesforce client portal

    ReplyDelete
  2. It appears that the install command has changed, and now you need to use the -p option, not the -i option.

    The scratch org definition file format has also been updated. Docs here: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file.htm

    And there's a "CPQ" feature that can be specified in that file as a pre-req to installing the CPQ package.

    And finally the ID changes for each version. The best way I found to get the ID is to run `sfdx force:package:installed:list` on an org that already has it installed, and copy the ID from the "Package Version ID" column. More options here: https://salesforce.stackexchange.com/questions/191068/installing-an-appexchange-app-into-a-scratch-org

    So for Summer '20 the command I used was:
    sfdx force:package:install -p 04t4N000000YTPyQAO -u <>

    ReplyDelete

CPQ Renewal Opportunity and Forecasting

In order to create Renewal Opportunity which will be used you need to refer to Contract. Contract object has a field called " SBQQ__R...