1. Create an Apex Class with a name 'quickQuoteController'.
public class quickQuoteController {
public pageReference genQuote()
{
String quoteId;
// MUST PASS ACCOUNT ID TO URL
Id acctId = ApexPages.currentPage().getParameters().get('aId');
// IF GENERATING A QUICK QUOTE FROM OPPORTUNITY, PASS OPPORTUNITY ID TO URL
Id oppId = ApexPages.currentPage().getParameters().get('oId');
// IF NO OPPORTUNITY ID IS PASSED TO THE URL, A NEW OPPORTUNITY IS CREATED
if(oppId==null){
Opportunity opp = new Opportunity(AccountID = acctId, stagename = 'Proposal/Price Quote', name = 'New Opportunity', closedate = Date.today());
Database.insert(opp);
oppId = opp.id;
}
// CREATE NEW QUOTE
SBQQ__Quote__c q = new SBQQ__Quote__c (SBQQ__Opportunity2__c = oppId, SBQQ__Status__c='Draft', SBQQ__Type__c='Quote', SBQQ__Account__c = acctId, SBQQ__Primary__c = true);
Database.Insert(q);
quoteId = q.Id;
// CONSTRUCT URL FOR CPQ CART
String sfdcBaseURL = URL.getOrgDomainUrl().toExternalForm();
//String targetURL = sfdcBaseURL.replace('-c.','-sbqq.') + '/apex/sbqq__sb?scontrolCaching=1&id='+quoteID+'#/product/lookup?qId='+quoteId+'&aId='+acctId;
String targetURL = sfdcBaseURL.replace('-c.','-sbqq.') + '/apex/sbqq__sb?id='+quoteID;
return new PageReference(targetURL);
}
}
2. Create a Visualforce page named quickQuotePage. Ensure the 'Available for Lightning Experience, Lightning Communities, and the mobile app' checkbox is true and enter the following in the Visualforce Markup:
<apex:page controller="quickQuoteController" action="{!genQuote}">
</apex:page>
3. Create a custom Button on the Opportunity object with the following Button Link URL:
/apex/quickQuotePage?oId={!Opportunity.Id}&aId={!Opportunity.AccountId}
000380525

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.