ffscpq.CreateProjectFromEstimateServiceglobal with sharing class CreateProjectFromEstimateService A service that provides functionality related to creating projects from estimate details. The service will also add estimate details to their related opportunities. MethodscreateProjectsFromEstimatesAsyncglobal static List<ffscpq.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncResponse> createProjectsFromEstimatesAsync(List<ffscpq.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncRequest> requests) A method that creates projects from estimate details. The method will also add details from the estimates to the related opportunities. Input Parameters
Return ValueThis service returns CreateProjectFromEstimateAsyncResponse 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 details you want to create a project from. A request is required for each project you want to create. Id estimateId = 'a6B5C0000004VrnUAE'; // Provide the request with details of the project to be created. pse__Proj__c project = new pse__Proj__c( Name = 'My Project', pse__Region__c = 'a2y7e0000017KIqAAM', pse__Start_Date__c = Date.newInstance(2022, 1, 1), CurrencyIsoCode = 'USD' ); // Provide the request with the estimate product IDs that you want to create a project from. If you want to create a project using 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.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncRequest request = new ffscpq.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncRequest( estimateId, project ); 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__Test__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.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncResponse> responses = ffscpq.CreateProjectFromEstimateService.createProjectsFromEstimatesAsync( new List<ffscpq.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncRequest>{ request } ); // Extract the response data System.debug('The estimate ID: ' + responses[0].EstimateId); System.debug('The created 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.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncRequestglobal with sharing class CreateProjectFromEstimateAsyncRequest The request structure for creating a project from an estimate. Properties
MethodsCreateProjectFromEstimateAsyncRequestglobal CreateProjectFromEstimateAsyncRequest(Id estimateId, pse__Proj__c projectDetails) 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 details you want to create a project from. A request is required for each project you want to create. Id estimateId = 'a6B5C0000004VrnUAE'; // The field values for the project to be created. pse__Proj__c project = new pse__Proj__c( Name = 'My Project', pse__Region__c = 'a2y7e0000017KIqAAM', pse__Start_Date__c = Date.newInstance(2022, 1, 1) ); // Provide the request with the estimate product IDs that you want to create a project from. If you want to create a project using 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.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncRequest request = new ffscpq.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncRequest( estimateId, project ); 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.AdditionalAggregationFields = new Set<String>{ 'ffscpq__Test__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.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncResponseglobal with sharing class CreateProjectFromEstimateAsyncResponse The response structure for creating a project from an estimate. Properties
ffscpq.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncErrorglobal with sharing class CreateProjectFromEstimateAsyncError The error that occurred while processing the request. Properties
|