ffscpqint.SyncEstimateAndQuoteServiceglobal with sharing class SyncEstimateAndQuoteService A service that provides functionality related to syncing details from estimates to their related quotes and vice versa. Methods
syncEstimateAndQuoteglobal static List<ffscpqint.SyncEstimateAndQuoteService.SyncEstimateAndQuoteResponse> syncEstimateAndQuote(List<ffscpqint.SyncEstimateAndQuoteService.SyncEstimateAndQuoteRequest> requests) A method that syncs estimate details to their related quotes and vice versa. Input Parameters
Return ValueThis service returns SyncEstimateAndQuoteResponse in a list that parallels the input list. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. Id estimateId = 'a6MDK000000L2fJ2AS'; // Id quoteId = 'a5Z6t000000EcEuEAK'; // You can optionally list the details to add to each estimate product instance being created by newly synced quote lines. // First, use the estimate ID to retrieve unsynced service quote line IDs and the estimate product IDs associated with the same product as the quote lines. // Construct the retrieveUnsyncedQuoteLines request ffscpqint.SyncEstimateAndQuoteService.RetrieveUnsyncedQuoteLinesRequest retrieveUnsyncedQuoteLinesRequest = new ffscpqint.SyncEstimateAndQuoteService.RetrieveUnsyncedQuoteLinesRequest(); // The ID of the estimate associated with the quote that the unsynced service quote lines are retrieved from. retrieveUnsyncedQuoteLinesRequest.EstimateId = estimateId; // Retrieve the unsynced service quote lines. These will be used when constructing the syncEstimateAndQuote request. List<ffscpqint.SyncEstimateAndQuoteService.RetrieveUnsyncedQuoteLinesResponse> retrieveUnsyncedQuoteLinesResponses = ffscpqint.SyncEstimateAndQuoteService.retrieveUnsyncedQuoteLines( new List<ffscpqint.SyncEstimateAndQuoteService.RetrieveUnsyncedQuoteLinesRequest>{ request } ); // Construct the syncEstimateAndQuote request ffscpqint.SyncEstimateAndQuoteService.SyncEstimateAndQuoteRequest request = new ffscpqint.SyncEstimateAndQuoteService.SyncEstimateAndQuoteRequest(); // You must specify either the ID of the quote or of the estimate. You can't specify both. // The ID of the estimate being synced. request.EstimateId = estimateId; // The ID of the quote being synced. // request.QuoteId = quoteId; // You can set this to true if you want to consolidate estimate role requests by skills when generating resource requests. // The estimate and the quote must both be primary to consolidate role requests. request.AggregateBySkills = false; // This is an optional setting that provides additional fields to consolidate estimate role requests by when generating resource requests. // The estimate and the quote must both be primary to consolidate role requests. request.AdditionalAggregationFieldPaths = new List<String>{ 'ffscpq__Estimate_Task__r.Name' }; // You can optionally specify the values of the estimate product instances to be created for each unsynced service quote line from the retrieveUnsyncedQuoteLines request. This is a mandatory step if there are multiple estimate products related to the product on the quote line. List<ffscpqint.SyncEstimateAndQuoteService.EstimateProductInstanceDetails> estimateProductInstanceDetails = new List<ffscpqint.SyncEstimateAndQuoteService.EstimateProductInstanceDetails>(); for (ffscpqint.UnsyncedQuoteLineDetail unsyncedQuoteLineDetail : retrieveUnsyncedQuoteLinesResponses[0].UnsyncedQuoteLines) { ffscpqint.SyncEstimateAndQuoteService.EstimateProductInstanceDetails estimateProductInstanceDetail = new ffscpqint.SyncEstimateAndQuoteService.EstimateProductInstanceDetails( unsyncedQuoteLineDetail.QuoteLineId ); // If there are multiple estimate products related to the service product, select the estimate product you want to use to sync with quote from the response list. estimateProductInstanceDetail.EstimateProductId = unsyncedQuoteLineDetail.EstimateProducts[1].Id; // This is an optional setting to specify the currency ISO code of each estimate product instance. estimateProductInstanceDetails[0].CurrencyIsoCode = 'USD'; estimateProductInstanceDetails.add(estimateProductInstanceDetail); } // Add the list of estimate product instance details to the request. request.EstimateProductInstancesDetails = estimateProductInstanceDetails; List<ffscpqint.SyncEstimateAndQuoteService.SyncEstimateAndQuoteResponse> responses = ffscpqint.SyncEstimateAndQuoteService.syncEstimateAndQuote( new List<ffscpqint.SyncEstimateAndQuoteService.SyncEstimateAndQuoteRequest>{ request } ); // Extract the response data System.debug('The estimate ID: ' + responses[0].EstimateId); System.debug('The quote ID: ' + responses[0].QuoteId); // Extract errors System.debug('Number of errors: ' + responses[0].Errors.size()); if (!responses[0].Errors.isEmpty()) { System.debug('Error message: ' + responses[0].Errors[0].Message); } retrieveUnsyncedQuoteLinesglobal static List<ffscpqint.SyncEstimateAndQuoteService.RetrieveUnsyncedQuoteLinesResponse> retrieveUnsyncedQuoteLines(List<ffscpqint.SyncEstimateAndQuoteService.RetrieveUnsyncedQuoteLinesRequest> requests) A method that retrieves the details of unsynced service quote lines from their related quote. Input Parameters
Return ValueThis service returns RetrieveUnsyncedQuoteLinesResponse in a list that parallels the input list. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Construct the request ffscpqint.SyncEstimateAndQuoteService.RetrieveUnsyncedQuoteLinesRequest request = new ffscpqint.SyncEstimateAndQuoteService.RetrieveUnsyncedQuoteLinesRequest(); // You must specify either the ID of the quote or of the estimate. You can't specify both. // The ID of the estimate associated with the quote that the unsynced service quote lines are retrieved from. request.EstimateId = 'a6MDK000000L2fJ2AS'; // The ID of the quote to retrieve unsynced service quote lines from. // request.QuoteId = 'a5Z6t000000EcEuEAK'; List<ffscpqint.SyncEstimateAndQuoteService.RetrieveUnsyncedQuoteLinesResponse> responses = ffscpqint.SyncEstimateAndQuoteService.retrieveUnsyncedQuoteLines( new List<ffscpqint.SyncEstimateAndQuoteService.RetrieveUnsyncedQuoteLinesRequest>{ request } ); // Extract the response data System.debug('The estimate ID: ' + responses[0].EstimateId); System.debug('The quote ID: ' + responses[0].QuoteId); // Extract the list of unsynced service quote line details List<ffscpqint.UnsyncedQuoteLineDetail> unsyncedQuoteLines = responses[0].UnsyncedQuoteLines; System.debug('Unsynced quote line ID: ' + unsyncedQuoteLines[0].QuoteLineId); System.debug('Unsynced quote line currency: ' + unsyncedQuoteLines[0].CurrencyIsoCode); // Extract the estimate products related to the service product on the unsynced quote line List<ffscpq__Estimate_Product__c> estimateProducts = unsyncedQuoteLines[0].EstimateProducts; // Extract the estimate product details System.debug('Estimate product ID: ' + estimateProducts[0].Id); System.debug('Estimate product Name: ' + estimateProducts[0].Name); System.debug('Estimate product related product: ' + estimateProducts[0].ffscpq__Product__c); // Extract errors System.debug('Number of errors: ' + responses[0].Errors.size()); if (!responses[0].Errors.isEmpty()) { System.debug('Error message: ' + responses[0].Errors[0].Message); } ffscpqint.SyncEstimateAndQuoteService.SyncEstimateAndQuoteRequestglobal with sharing class SyncEstimateAndQuoteRequest The request structure for syncing an estimate to its related quote and vice versa. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Construct the request ffscpqint.SyncEstimateAndQuoteService.SyncEstimateAndQuoteRequest request = new ffscpqint.SyncEstimateAndQuoteService.SyncEstimateAndQuoteRequest(); // You must specify either the ID of a quote or of a estimate. You can't specify both. // The ID of the estimate being synced. request.EstimateId = 'a6MDK000000L2fJ2AS'; // The ID of the quote being synced. // request.QuoteId = 'a5Z6t000000EcEuEAK'; // You can set this to true if you want to consolidate estimate role requests by skills when generating resource requests. // The estimate and the quote must both be primary to consolidate role requests. request.AggregateBySkills = false; // This is an optional setting that provides additional fields to consolidate estimate role requests by when generating resource requests. // The estimate and the quote must both be primary to consolidate role requests. request.AdditionalAggregationFieldPaths = new List<String>{ 'ffscpq__Estimate_Task__r.Name' }; // You can optionally list the details to add to each estimate product instance being created by newly synced quote lines. // First, use the quote ID to get unsynced quote line IDs and the estimate product IDs associated with the same product as the quote lines. ffscpq__Estimate__c estimate = [SELECT ffscpqint__Quote__c FROM ffscpq__Estimate__c WHERE Id = 'a6V6t000000t4AfEAI' LIMIT 1]; Id quoteId = estimate.ffscpqint__Quote__c; List<SBQQ__QuoteLine__c> unsyncedQuoteLines = [ SELECT Id, CurrencyIsoCode, SBQQ__Product__c FROM SBQQ__QuoteLine__c WHERE SBQQ__Quote__c = :quoteId AND SBQQ__Product__r.pse__IsServicesProduct__c = TRUE AND ffscpqint__Estimate__c = NULL ]; // Map the quote lines to their products IDs. Map<Id, List<SBQQ__QuoteLine__c>> quoteLinesByProductId = new Map<Id, List<SBQQ__QuoteLine__c>>(); for (SBQQ__QuoteLine__c quoteLine : unsyncedQuoteLines) { List<SBQQ__QuoteLine__c> existingQuoteLines = quoteLinesByProductId.get( quoteLine.SBQQ__Product__c ); if (existingQuoteLines == null) { existingQuoteLines = new List<SBQQ__QuoteLine__c>(); quoteLinesByProductId.put(quoteLine.SBQQ__Product__c, existingQuoteLines); } existingQuoteLines.add(quoteLine); } // Select the estimate products related to the same product IDs as the unsynced quote lines. Set<Id> productIds = quoteLinesByProductId.keySet(); List<ffscpq__Estimate_Product__c> estimateProducts = [ SELECT Id, ffscpq__Product__c, Name FROM ffscpq__Estimate_Product__c WHERE ffscpq__Product__c IN :productIds ]; // Map the estimate products to their product IDs. Map<Id, List<ffscpq__Estimate_Product__c>> estimateProductsByProductId = new Map<Id, List<ffscpq__Estimate_Product__c>>(); for (ffscpq__Estimate_Product__c estimateProduct : estimateProducts) { List<ffscpq__Estimate_Product__c> existingEstimateProducts = estimateProductsByProductId.get( estimateProduct.ffscpq__Product__c ); if (existingEstimateProducts == null) { existingEstimateProducts = new List<ffscpq__Estimate_Product__c>(); estimateProductsByProductId.put( estimateProduct.ffscpq__Product__c, existingEstimateProducts ); } existingEstimateProducts.add(estimateProduct); } // For each quote line, check if the related product is also related to an estimate product. // If it does, add to an estimate product instance to the list with details of the quote line. List<ffscpqint.SyncEstimateAndQuoteService.EstimateProductInstanceDetails> estimateProductInstanceDetails = new List<ffscpqint.SyncEstimateAndQuoteService.EstimateProductInstanceDetails>(); for (Id productId : estimateProductsByProductId.keySet()) { ffscpq__Estimate_Product__c estimateProduct = estimateProductsByProductId.get( productId )[0]; for (SBQQ__QuoteLine__c quoteLine : quoteLinesByProductId.get(productId)) { ffscpqint.SyncEstimateAndQuoteService.EstimateProductInstanceDetails estimateProductInstanceDetail = new ffscpqint.SyncEstimateAndQuoteService.EstimateProductInstanceDetails( quoteLine.Id ); estimateProductInstanceDetails.add(estimateProductInstanceDetail); } } // This is an optional setting to specify the estimate product ID of each estimate product instance. estimateProductInstanceDetail[0].EstimateProductId = 'a6P6t000000Ip84EAC'; // This is an optional setting to specify the currency ISO code of each estimate product instance. estimateProductInstanceDetails[0].CurrencyIsoCode = 'USD'; // This is an optional setting to add the estimate product instance details list to the request. request.EstimateProductInstancesDetails = estimateProductInstanceDetails Properties
MethodsSyncEstimateAndQuoteRequestglobal SyncEstimateAndQuoteRequest() ffscpqint.SyncEstimateAndQuoteService.RetrieveUnsyncedQuoteLinesRequestglobal with sharing class RetrieveUnsyncedQuoteLinesRequest The request structure for retrieving unsynced service quote lines from a quote. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Construct the request ffscpqint.SyncEstimateAndQuoteService.RetrieveUnsyncedQuoteLinesRequest request = new ffscpqint.SyncEstimateAndQuoteService.RetrieveUnsyncedQuoteLinesRequest(); // You must specify either the ID of a quote or of a estimate. You can't specify both. // The ID of the estimate. request.EstimateId = 'a6MDK000000L2fJ2AS'; // The ID of the quote. // request.QuoteId = 'a5Z6t000000EcEuEAK'; Properties
MethodsRetrieveUnsyncedQuoteLinesRequestglobal RetrieveUnsyncedQuoteLinesRequest() ffscpqint.SyncEstimateAndQuoteService.SyncEstimateAndQuoteResponseglobal with sharing class SyncEstimateAndQuoteResponse The result returned after syncing an estimate with its related quote and vice versa. Properties
ffscpqint.SyncEstimateAndQuoteService.RetrieveUnsyncedQuoteLinesResponseglobal with sharing class RetrieveUnsyncedQuoteLinesResponse The result returned containing details of unsynced service quote lines. Properties
ffscpqint.SyncEstimateAndQuoteService.SyncEstimateAndQuoteErrorglobal with sharing class SyncEstimateAndQuoteError The error that occurred while processing the request. Properties
ffscpqint.SyncEstimateAndQuoteService.EstimateProductInstanceDetailsglobal with sharing class EstimateProductInstanceDetails The details of the estimate product instance being created by newly synced quote lines. Properties
MethodsEstimateProductInstanceDetailsglobal EstimateProductInstanceDetails(Id quoteLineId) Input Parameters
|