Thursday 22 February 2018

Salesforce CPQ- Product Bundling

A collection of products that are sold together called bundle.
A bundle is a product itself , also component of bundle maybe sold separately or maybe not.


For example if you are selling computer case with all components like CPU , RAM, VGA, Mother Board . maybe you would like to sell CPU separately or just via the bundle product.

In order to set a product as bundle you need to specify the options on the product or component of the product , this can be set on Product Option .

Consider you have a product called "Dell Desktop Computer" , you need to define options but before that just see if you can categorize those options, so sales users can choose those options easier. these categories are like Processor, RAM, ... as there are multiple CPUs that can be selected when selling this product.

If you need to create those category click on "New Product Feature" on the product layout.

Then go ahead and all other required features, Number field on product option is going to determine the order of displaying features in Quote line configuration.


It's a best practice to set the number like 10, 20 ,30 so if later on you would like to change the order, you don't need to update the order of all features.

Now go ahead and add new product option to this product like a CPU(this product should be already available in your product list)


The most important field in product option is Type , it has the following values

  • Component : Quantity is depending on its parent, and it needs to be required.
  • Accessory : This is a dependent option but Quantity is not depending on its parent.
  • Related Product : Fully independent to its parent (this can be used for cross sell or upsell)
  • None: similar to component


In product option you can also specify the required filed and min and max number of product option in the bundle. Unit price , if this is set this will override the value from pricebook.

Then next option that can be set is "Option Constraints", by using this you can specify the required logic for selecting a product option.

Quote Line Visibility on Product Option

If there is a bundle product and you don't want to display the component as a separated line in quote line editor after bundle gets configured then , set Quote Line Visibility to Document Only.

These are the different values for Quote Line Visibility:

  • None
  • Editor Only (Quote Line Editor | QLE)
  • Document Only (Quote Template)
  • Never
So by using Quote line visibility on product option , you can control of you would like to display the product option in Quote Line Editor or Quote Document , or not.

Salesforce CPQ Configuration


  • CPQ Calculator

CPQ has two Calculators that being used in Quote Line Editor.

By Default the one that it's enabled is a server side calculator , which means each request needs to call a server side event , this is also called as legacy calculator.

The new calculator is not turn on , in order to turn the new client side calculator you need to go to setup-> install packaged - > CPQ package and click on Configure and on "Pricing and Calculation" tap, set authorize the new calculator service.

Legacy Calculator

  • Server Side
  • Apex
  • Debug log
New Calcolator
  • Client Side
  • Javascript
  • Browser Debug
I recommend to go ahead and authorize the new calculator in your org.


  • Prorate Precision and Term

Another option that can be set on CPQ configuration section is setting Prorate Precision and Subsciption Term units.



Term is used in the product and some other objects , the value can be Month and Day be default

To give you an example, if you are selling a subscription product you can specify the Subscription Term to 12 and Term in the CPQ config set to Month then in the  Quote line/Opportunity line quantity of this item is 1. this means you are going to provide that service for 12 month.(Length of the term is 12 month)



Now if you are always selling this product for 12 months then it's all good but usually this is not the case, you might sell this product for 12 months and 15 days or 6 months in reality.

So there is two options here first option is saying if customer wants to buy that service/product for less than 12 months , he/she needs to pay 12 months anyway.

The next option is prorate that to what customer is going to buy , like if buying it for 6 months and 10 days, 5 months and 20 days needs to be reduced from the price(Prorate needs to be set to Monthly+Daily ) or customer needs to pay 7 months and only 5 months needs to be reduced (Prorate needs to be set to Month)


  • Solution Group

Enabling Solution Group would be useful if you are grouping line items usually when selling your products ,


  • Renewal Mode

This can be based on Contract or Assets, regardless of model Renewal Opportunity and Quote will get created.

Salesforce CPQ Pricing Structure


There is a specific order that price and discounts applies in CPQ product and remember This order cannot be changed.

  1. Original Price
  2. List Price
    • System Discounts -> Discount Schedules, like Volume based discount
  3. Regular Price
    •  Special Price, Contracted Price, Additional discounts ( manually added)
  4. Customer Price
    • Partner discount
  5. Partner Price
    • Distributor discount
  6. Net Price


Note : Applying discount on a wrong price might cause some strange behavior, (Like Net price instead of List or regular price)

Setting Special Price
If you would like to set the Special price, remember you need to set the Special Price Type to Custom as well.


Wednesday 21 February 2018

Twin Fields in CPQ and Salesforce

Twin field is a new term that introduced by CPQ and it has some similarity to formula field in salesforce.

If you are coming from programming background , definitely you have heard about auto-mapper which basically maps to fields between two objects if the field name and type are the same.

If you don't have programming background, nothing to worry about as it is simple.Basically the requirement is mapping two fields in two objects if the name and type are exactly the same.

CPQ Twin Fields

CPQ Twin Fields

To give you an example , consider you like to have access to a field you created or existed in Product object in Quote Line. Based on the above, auto mapping is available between these two objects, and if you have a field called "MyField__c" on product as a text or picklist  that wanted to map to Quote line , go to Quote line object and create exactly the same field name "MyField__c" with text or picklist, and that's it.

Now if you set some value to that field in product the the value automatically will be available on  Quote line, this value can be used later for some filtering or ...


CPQ Product basic configuration

I recently went to the salesforce CPQ training and found it really useful so decided to share my knowledge as I still can remember :) with everyone else as there are not many resources available.


If this is a fresh org without any data first you need to add product family.
Go to Setup -> Product -> fields -> Product Family and add your product families to the picklist values



I only added hardware as a product family.

Then go to product and add new product.


I added "Dell laptop" and selected the "Hardware" as the product family and make sure you click on Active checkbox/


After installing CPQ package you need to change some of the existing layout of the objects, Now let's start with Product object, by default all profiles can see the default layout of product layout.
Go to product pay layout assignment

And click on Page Layout assignment -> Edit assignment and assign CPQ product layout to all profiles and save it.

Go to the one of existing product and view it, this time you should be able to see a layout like this :


Based on the product you selling , you might have a subscription product like selling a licence with some duration or service with some duration or a a laptop,...

All product behavior cane be set here , then later on you can see it in Quote Line Editor.

The first item is Pricing method, this can be List, Block and Cost.
The second item is Subscription products.


If the product you are selling is like a service or licence with subscription then in the "Subscription" section it needs to be configured.

Subscription Pricing can be fixed price , subscription terms can be 1 , also you can say if this product is renewable or not ,...

The other option for subscription pricing can be "percent of total" this is more like a warrant service or administration service that can be applied based on the amount of other selling product, to give you more specific example this can be you are selling a laptop and now you would like to add warranty , the warranty itself is a product with subscription pricing of percent of total , then you need to specify the subscription percentage like 5% or 10%


The last item is bundle configuration.

Note: In order to set the term in you org, go to setup-> install package-> CPQ package and click on configure , then go to Subscription and Renewals tab and set the related "Subscription Term Unit" to Month or day. plus you can set the "Subscription Prorate Precision" to Day, Month, Month+Day


Consider there are two product with following information and term setting is Month and Prorate is Month

LicenseProduct , Term : 1, price :fixed $10

SupportProduct, Term :12, price: fixed $20

Now if you want to create a quote for 3 months and 15 days and 1 quantity the calculation would be

LicenseProduct  1*4 month(because prorate is month) *10 = $40
SupportProduct 1* (4/12) * 20 = *20 = $6.66



How to calculate Prorate Multiplier 

Consider a scenario which start date of a subscription is 1/July/2017 and end date is 1/July/2018.
If prorate multiplier needs to be calculated for different Term and Prorate precision, also consider the term of the product covers whole 1 year (12 months or 365 days).

366 days or 12 Months and 1 day in 1/July/2017 -  1/July/2018 period

Prorate Multiplier : Subscription duration / Subscription term duration

Scenario 1
Term : Month
Product term:12
Prorate Precision : Monthly


Prorate Multiplier : 13 / 12 = 1.0833

Scenario 2
Term : Day
Product term:365
Prorate Precision : Daily

Prorate Multiplier : 366/365 = 1.0027

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


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...