ffscpq.AddToOpportunityFromEstimateServiceglobal with sharing class AddToOpportunityFromEstimateService A service that provides functionality related to adding details from estimates to their related opportunities. MethodsaddToOpportunitiesFromEstimatesAsyncglobal static List<ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncResponse> addToOpportunitiesFromEstimatesAsync(List<ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequest> requests) A method that adds estimate details to their related opportunities by creating resource requests and opportunity products. Input Parameters
Return ValueThis service returns AddToOpportunityFromEstimateAsyncResponse 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. // The ID of the primary estimate that contains the details you want to add to the related opportunity. A request is required for each estimate you want to add to opportunity. Id estimateId = 'a6B5C0000004VrnUAE'; // Provide the request with the estimate product IDs that you want to add details from. If you want to add all of the estimate products, you can select them all as shown in this example. List<ffscpq__Estimate_Product_Instance__c> estimateProductInstances = [ SELECT Id FROM ffscpq__Estimate_Product_Instance__c WHERE ffscpq__Estimate__c = :estimateId ]; Set<Id> estimateProductInstanceIds = new Map<Id, ffscpq__Estimate_Product_Instance__c>( estimateProductInstances ) .keySet(); // Construct the request. ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequest request = new ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequest( estimateId ); request.EstimateProductIds = estimateProductInstanceIds; // You can optionally disable records independent of estimate products so that they are not included. request.IncludeRecordsIndependentOfEstimateProducts = false; // This is an optional setting that provides additional fields to consolidate estimate role requests by when generating resource requests. request.AdditionalAggregationFieldPaths = new List<String>{ 'ffscpq__Estimate_Task__r.Name', 'ffscpq__Region__c' }; // You can set this to false if you don't want to consolidate estimate role requests by skills when generating resource requests. request.AggregateBySkills = false; // You can set this to false if you don't want to create opportunity line items. request.CreateOpportunityLineItems = false; List<ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncResponse> responses = ffscpq.AddToOpportunityFromEstimateService.addToOpportunitiesFromEstimatesAsync( new List<ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequest>{ request } ); // Extract the response data System.debug('The estimate ID: ' + responses[0].EstimateId); // Extract errors System.debug('Number of errors: ' + responses[0].Errors.size()); for ( ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncError error : responses[0] .Errors ) { System.debug(error.Message); } ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequestglobal with sharing class AddToOpportunityFromEstimateAsyncRequest The request structure for adding an estimate to its related opportunity. Properties
MethodsAddToOpportunityFromEstimateAsyncRequestglobal AddToOpportunityFromEstimateAsyncRequest(Id estimateId) A default constructor with minimum required properties. Input Parameters
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. // The ID of the primary estimate that contains the details you want to add to the related opportunity. A request is required for each estimate you want to add to opportunity. Id estimateId = 'a6B5C0000004VrnUAE'; // Provide the request with the estimate product IDs that you want to add details from. If you want to add all of the estimate products, you can select them all as shown in this example. List<ffscpq__Estimate_Product_Instance__c> estimateProductInstances = [ SELECT Id FROM ffscpq__Estimate_Product_Instance__c WHERE ffscpq__Estimate__c = :estimateId ]; Set<Id> estimateProductInstanceIds = new Map<Id, ffscpq__Estimate_Product_Instance__c>( estimateProductInstances ) .keySet(); // Construct the request. ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequest request = new ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequest( estimateId ); request.EstimateProductIds = estimateProductInstanceIds; // You can optionally disable records independent of estimate products so that they are not included. request.IncludeRecordsIndependentOfEstimateProducts = false; // This is an optional setting that provides additional fields to consolidate estimate role requests by when generating resource requests. request.AdditionalAggregationFieldPaths = new List<String>{ 'ffscpq__Estimate_Task__r.Name', 'ffscpq__Region__c' }; // You can set this to false if you don't want to consolidate estimate role requests by skills when generating resource requests. request.AggregateBySkills = false; // You can set this to false if you don't want to create opportunity line items. request.CreateOpportunityLineItems = false; ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncResponseglobal with sharing class AddToOpportunityFromEstimateAsyncResponse The response structure for adding an estimate to its related opportunity. Properties
ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncErrorglobal with sharing class AddToOpportunityFromEstimateAsyncError The error that occurred while processing the request. Properties
|