You are here:
SyncToOpportunity
Synchronize the line items of a quote to its parent opportunity, deleting existing opportunity line items and copying existing quote line items.
Interface
ConfigurePriceQuoteControllerInterface
Sample Code
/***
* @group Implementations
*
* @description strongly typed interface: ConfigurePriceQuoteControllerInterface <br>
* <1>Intro and Purpose: Synchronize quote back to parent oppty. <br>
* This code is a wrapper to call the SyncQuoteToOpptyInterface which is where customer modifications would likely happen<br>
* <2>Triggering the Interface: Sync to Opportunity button on Quote > Review Cart <br>
* <3> Other Implementations: There are other uses of this wrapper class. For example CreateOrders.cls. <br>
* But there are no additional implementations for Syncing a Quote to an Oppty
**/
global with sharing class SyncToOpportunity implements GlobalInterfaces.ConfigurePriceQuoteControllerInterface
{
/**
* @description Entry method of interface. Called by button on Quote: "Sync To Opportunity"
* @param parentItemId (Id) ie QuoteId
* @param parentItem (SObject) ie Quote
* @param displayItemsList (List<ItemWrapper>) ie LineItems from quote
* @return ObjectCopier which contains the page reference to the Oppty that you are syncing to.
*/
global ObjectCopier createCpq(Id parentItemId, SObject parentItem, List<ItemWrapper> displayItemsList)
{
ObjectCopier oc = new ObjectCopier();
Savepoint sp = Database.setSavepoint();
system.debug(':::parentItemId:' + parentItemId + ' displayItemsList: ' + displayItemsList);
try
{
string ae = CustomSettingsUtilities.getCustomClassImplemenationName('SyncQuoteToOppty');
Type t = Type.forName(ae);
system.debug(':::t in SyncToOpportunity:' + t);
//Use interface so customers can modify logic
try
{
GlobalInterfaces.SyncQuoteToOpptyInterface syncQuoteInterface = (GlobalInterfaces.SyncQuoteToOpptyInterface)t.newInstance();
oc = syncQuoteInterface.createCpq(parentItemId, parentItem, displayItemsList);
}
catch(Exception e)
{
string message = 'Invalid implementation: SyncQuoteToOptyInterface';
Logger.err(new InvalidImplementationException(message));
ApexPages.addMessages(new InvalidImplementationException(message));
return oc;
}
return oc;
}
catch(Exception e)
{
Database.rollback(sp);
oc.NewObjectId = '';
oc.Status = e.getMessage();
return oc;
}
}
public class InvalidImplementationException extends Exception
{
}
}Related Implementations
-
CreateAssetCreateAsset
-
CreateOrderCreateOrder
-
CreateQuoteCreateQuote

