ffscpq.AddToProjectFromEstimateServiceglobal with sharing class AddToProjectFromEstimateService A service that provides functionality related to adding estimate records to a project. The service will also add estimate records to their related opportunities. MethodsaddToProjectsFromEstimatesAsyncglobal static List<ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncResponse> addToProjectsFromEstimatesAsync(List<ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequest> requests) A method that adds estimate records to a project. The method will also add records from the estimates to the related opportunities. Input Parameters
Return ValueThis service returns AddToProjectFromEstimateAsyncResponse 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 estimate that contains the records you want to add to a project. A request is required for each project you want to add to. Id estimateId = 'a6B5C0000004VrnUAE'; // The ID of the project you want to add to. It must be associated with the same opportunity as the estimate and in the same currency as the estimate products being added. Id projectId = 'a2W6s000000pjyTEAQ'; // Provide the request with the estimate product IDs that you want to add to a project. 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.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequest request = new ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequest( estimateId, projectId ); request.EstimateProductIds = estimateProductInstanceIds; // You can optionally disable records independent of estimate products so that they are not included in the project. 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_Role_Request__c.Test__c', 'ffscpq__Estimate_Role_Request__c.ffscpq__Estimate_Task__r.Custom_Field__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.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncResponse> responses = ffscpq.AddToProjectFromEstimateService.addToProjectsFromEstimatesAsync( new List<ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequest>{ request } ); // Extract the response data System.debug('The estimate ID: ' + responses[0].EstimateId); System.debug('The project ID: ' + responses[0].ProjectId); // 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); } ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequestglobal with sharing class AddToProjectFromEstimateAsyncRequest The request structure for adding estimate records to a project. Properties
MethodsAddToProjectFromEstimateAsyncRequestglobal AddToProjectFromEstimateAsyncRequest(Id estimateId, Id projectId) 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 estimate that contains the records you want to add to a project. A request is required for each project you want to add to. Id estimateId = 'a6B5C0000004VrnUAE'; // The ID of the project you want to add to. It must be associated with the same opportunity as the estimate and in the same currency as the estimate products being added. Id projectId = 'a2W6s000000pjyTEAQ'; // Provide the request with the estimate product IDs that you want to add to a project. 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.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequest request = new ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequest( estimateId, projectId ); request.EstimateProductIds = estimateProductInstanceIds; // You can optionally disable records independent of estimate products so that they are not included in the project. 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_Role_Request__c.Test__c', 'ffscpq__Estimate_Role_Request__c.ffscpq__Estimate_Task__r.Custom_Field__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.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncResponseglobal with sharing class AddToProjectFromEstimateAsyncResponse The response structure for adding estimate records to a project. Properties
ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncErrorglobal with sharing class AddToProjectFromEstimateAsyncError The error that occurred while processing the request. Properties
|