Services CPQ API Developer Reference

ffscpq.AddFromEstimateTemplateService

global with sharing class AddFromEstimateTemplateService

A service that provides functionality related to copying all related records from one estimate to another.

Methods

addAllRelatedRecords

global static List<ffscpq.AddFromEstimateTemplateService.AddAllRelatedRecordsResponse> addAllRelatedRecords(List<ffscpq.AddFromEstimateTemplateService.AddAllRelatedRecordsRequest> requests)

A method that copies all related records from an estimate.

Input Parameters

Name Type Description
requests List<ffscpq.AddFromEstimateTemplateService.AddAllRelatedRecordsRequest> The list of AddAllRelatedRecordsRequest. The number of unique target estimates cannot exceed 50 within all requests.

Return Value

This 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.AddAllRelatedRecordsRequest

global with sharing class AddAllRelatedRecordsRequest

The request structure for copying all related records from an estimate.

Properties

Name Type Description
SourceEstimateId Id The estimate to copy related records from.
DestinationEstimateId Id The estimate to copy related records to.
StartDate Date [Optional] The start date of the copied records will be offset relative to this date instead of target estimate start date. You can't specify a start date if you've specified an end date.
EndDate Date [Optional] The end date of the copied records will be offset relative to this date. You can't specify an end date if you've specified a start date.
IncludeSkills Boolean If true, skills are copied from the existing estimate to the new estimate. The default value is true.
IncludeEstimatedExpenses Boolean If true, estimated expenses are copied from the existing estimate to the new estimate. The default value is true.
IncludeEstimatePhases Boolean If true, estimate phases are copied from the existing estimate to the new estimate. The default value is false.
IncludeEstimateVendorLineItems Boolean If true, vendor line items are copied from the existing estimate to the new estimate. The default value is true.
IncludeSchedules Boolean If true, schedules are copied from the existing estimate to the new estimate. The default value is true.
UseSourceTemplateCurrencies Boolean If true, estimate product instances and their related records are copied in their original currencies. If false, they are converted to the target estimate currency. Records independent of estimate products are always converted to the target estimate currency. The default value is false.
FieldOverridesByType Map<SObjectType, Map<SObjectField, Object>> [Optional] The specified object fields will be overridden to the supplied values. Supported Objects: ffscpq__Estimate_Line_Set__c ffscpq__Estimate_Task__c ffscpq__Estimate_Role_Request__c ffscpq__Estimated_Expense__c ffscpq__Estimate_Vendor_Line_Item__c ffscpq__Estimate_Role_Skill_Request__c
--- Unsupported Fields: CurrencyIsoCode ffscpq__Start_Date__c ffscpq__End_Date__c Hierarchy Lookups (for example, ffscpq__Estimate_Task__c.ffscpq__Estimate__c) Rollup fields on records (for example, ffscpq__Net_Bill_Amount__c, ffscpq__Cost_Amount__c, ffscpq__Bill_Amount__c), except additional cost rollups, such as estimated expense amounts

Methods

AddAllRelatedRecordsRequest

global AddAllRelatedRecordsRequest(Id sourceEstimateId, Id destinationEstimateId)

A default constructor with minimum required properties.

Input Parameters

Name Type Description
sourceEstimateId Id The ID of the source estimate.
destinationEstimateId Id The ID of the target estimate.

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.AddAllRelatedRecordsResponse

global with sharing class AddAllRelatedRecordsResponse

The result returned after copying all related record from an estimate.

Properties

Name Type Description
SourceEstimateId Id The estimate that related records were copied from.
DestinationEstimateId Id The estimate that related records were copied to.
JobId Id The AsyncApexJob ID. If this is null, the request was not processed due to an error.
Errors List<ffscpq.AddFromEstimateTemplateService.AddFromEstimateTemplateError> A list containing errors that occurred while processing the request.

ffscpq.AddFromEstimateTemplateService.AddFromEstimateTemplateError

global with sharing class AddFromEstimateTemplateError

The error that occurred while processing the request.

Properties

Name Type Description
Message String The error message.
© Copyright 2009–2024 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.