ffscpq.AddFromEstimateTemplateServiceglobal with sharing class AddFromEstimateTemplateService A service that provides functionality related to copying all related records from one estimate to another. MethodsaddAllRelatedRecordsglobal static List<ffscpq.AddFromEstimateTemplateService.AddAllRelatedRecordsResponse> addAllRelatedRecords(List<ffscpq.AddFromEstimateTemplateService.AddAllRelatedRecordsRequest> requests) A method that copies all related records from an estimate. Input Parameters
Return ValueThis service returns AddAllRelatedRecordsResponse 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 you want to copy records from. Id sourceEstimateId = 'a6CF20000007Z1ZeAQ'; // The ID of the estimate that you want to copy records to. Id destinationEstimateId = 'a6C320000007Z1eEaA'; // Construct the request ffscpq.AddFromEstimateTemplateService.AddAllRelatedRecordsRequest request = new ffscpq.AddFromEstimateTemplateService.AddAllRelatedRecordsRequest( sourceEstimateId, destinationEstimateId ); // You can optionally set this to false if you dont want to copy skills. request.IncludeSkills = false; // You can optionally set this to false if you dont want to copy estimated expenses. request.IncludeEstimatedExpenses = false; // You can optionally set this to false if you dont want to copy estimate vendor line items. request.IncludeEstimateVendorLineItems = false; // You can optionally set the StartDate if you dont want to offset the start date of copied records relative to target estimate start date. request.StartDate = Date.newInstance(2023, 1, 1); // You can optionally set the EndDate if you dont want to offset the end date of copied records relative to template estimate end date. request.EndDate = Date.newInstance(2023, 2, 1); // You can optionally specify object fields to override for the copied records. Id unitedStatesRegion = 'a2y7i000003396bAAA'; request.FieldOverridesByType = new Map<SObjectType, Map<SObjectField, Object>>{ ffscpq__Estimate_Role_Request__c.SObjectType => new Map<SObjectField, Object>{ // Set the region for all copied role requests to the United States region. ffscpq__Estimate_Role_Request__c.ffscpq__Region__c => unitedStatesRegion } }; List<ffscpq.AddFromEstimateTemplateService.AddAllRelatedRecordsResponse> responses = ffscpq.AddFromEstimateTemplateService.addAllRelatedRecords( new List<ffscpq.AddFromEstimateTemplateService.AddAllRelatedRecordsRequest>{ request } ); // Extract the response data System.debug('The source estimate ID: ' + responses[0].SourceEstimateId); System.debug('The destination estimate ID: ' + responses[0].DestinationEstimateId); System.debug('The ApexJobId: ' + responses[0].JobId); // 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.AddFromEstimateTemplateService.AddAllRelatedRecordsRequestglobal with sharing class AddAllRelatedRecordsRequest The request structure for copying all related records from an estimate. Properties
MethodsAddAllRelatedRecordsRequestglobal AddAllRelatedRecordsRequest(Id sourceEstimateId, Id destinationEstimateId) 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 estimate that you want to copy records from. Id sourceEstimateId = 'a6CF20000007Z1ZeAQ'; // The ID of the estimate that you want to copy records to. Id destinationEstimateId = 'a6C320000007Z1eEaA'; // Construct the request ffscpq.AddFromEstimateTemplateService.AddAllRelatedRecordsRequest request = new ffscpq.AddFromEstimateTemplateService.AddAllRelatedRecordsRequest( sourceEstimateId, destinationEstimateId ); // You can optionally set this to false if you dont want to copy skills. request.IncludeSkills = false; // You can optionally set this to false if you dont want to copy estimated expenses. request.IncludeEstimatedExpenses = false; // You can optionally set this to false if you dont want to copy estimate vendor line items. request.IncludeEstimateVendorLineItems = false; // You can optionally set the StartDate if you dont want to offset the start date of copied records relative to target estimate start date. request.StartDate = Date.newInstance(2023, 1, 1); // You can optionally set the EndDate if you dont want to offset the end date of copied records relative to template estimate end date. request.EndDate = Date.newInstance(2023, 2, 1); // You can optionally specify object fields to override for the copied records. Id unitedStatesRegion = 'a2y7i000003396bAAA'; request.FieldOverridesByType = new Map<SObjectType, Map<SObjectField, Object>>{ ffscpq__Estimate_Role_Request__c.SObjectType => new Map<SObjectField, Object>{ // Set the region for all copied role requests to the United States region. ffscpq__Estimate_Role_Request__c.ffscpq__Region__c => unitedStatesRegion } }; ffscpq.AddFromEstimateTemplateService.AddAllRelatedRecordsResponseglobal with sharing class AddAllRelatedRecordsResponse The result returned after copying all related record from an estimate. Properties
ffscpq.AddFromEstimateTemplateService.AddFromEstimateTemplateErrorglobal with sharing class AddFromEstimateTemplateError The error that occurred while processing the request. Properties
|