Services Estimator API Developer Reference

ffscpq.AddEstimateProductService

global with sharing class AddEstimateProductService

A service that provides functionality related to adding estimate products to estimates.

Methods

addEstimateProductsToEstimates

global static List<ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesResponse> addEstimateProductsToEstimates(List<ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequest> requests)

A method that adds estimate products to estimates.

Input Parameters

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

Return Value

This service returns AddEstimateProductsToEstimatesResponse 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 add the estimate product to.
Id estimateId = 'a6MDK000000L2fJ2AS';

// The ID of the estimate product that you want to add to the estimate.
Id estimateProductId = 'a6HDK000000L2uu2AC';

// Construct the request
ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequest request = new ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequest(
    estimateId,
    estimateProductId
);

// You can optionally set the billing type to change from the estimate product default.
request.EstimateProductInstanceBillingType = 'Fixed Price';

// You can optionally set the fixed price billing frequency to change from the estimate product default.
request.EstimateProductInstanceFixedPriceBillingFrequency = 'Line Set End Date';

// You can optionally set the fixed price upfront billing percent to change from the estimate product default.
request.EstimateProductInstanceFixedPriceUpfrontBillingPercent = 50;

// If billing type is specified as Fixed Price or you want to change from the default fixed price margin, you can set it here.
request.EstimateProductInstanceFixedPriceMargin = 15;

// You can optionally set the name of the created estimate product instance.
request.Name = 'Delivery & Support';

// You can optionally set the start date of the created estimate product instance if you want it offset from the target estimate start date.
request.StartDate = Date.newInstance(2023, 1, 1);

// You can optionally set the payment terms to change from the estimate product default.
request.EstimateProductInstancePaymentTerms = 'a5bEc000002GzXqIAK';

// 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.AddEstimateProductService.AddEstimateProductsToEstimatesResponse> responses = ffscpq.AddEstimateProductService.addEstimateProductsToEstimates(
    new List<ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequest>{ request }
);

// Extract the response data
System.debug('The estimate product ID: ' + responses[0].EstimateProductId);
System.debug('The destination estimate ID: ' + responses[0].EstimateId);
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);
}

addEstimateProductsToEstimatesSync

global static List<ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesSyncResponse> addEstimateProductsToEstimatesSync(List<ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequest> requests)

A method that synchronously adds estimate products to estimates.

Input Parameters

Name Type Description
requests List<ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequest> The list of AddEstimateProductsToEstimatesRequest.

Return Value

AddEstimateProductsToEstimatesSyncResponse list parallel to the input.

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 add the estimate product to.
Id estimateId = 'a6MDK000000L2fJ2AS';

// The ID of the estimate product that you want to add to the estimate.
Id estimateProductId = 'a6HDK000000L2uu2AC';

// Construct the request
ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequest request = new ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequest(
    estimateId,
    estimateProductId
);

// You can optionally set the billing type to change from the estimate product default.
request.EstimateProductInstanceBillingType = 'Fixed Price';

// You can optionally set the fixed price billing frequency to change from the estimate product default.
request.EstimateProductInstanceFixedPriceBillingFrequency = 'Line Set End Date';

// You can optionally set the fixed price upfront billing percent to change from the estimate product default.
request.EstimateProductInstanceFixedPriceUpfrontBillingPercent = 50;

// If billing type is specified as Fixed Price or you want to change from the default fixed price margin, you can set it here.
request.EstimateProductInstanceFixedPriceMargin = 15;

// You can optionally set the name of the created estimate product instance.
request.Name = 'Delivery & Support';

// You can optionally set the start date of the created estimate product instance if you want it offset from the target estimate start date.
request.StartDate = Date.newInstance(2023, 1, 1);

// You can optionally set the payment terms to change from the estimate product default.
request.EstimateProductInstancePaymentTerms = 'a5bEc000002GzXqIAK';

// 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
    }
};

// Unlike addEstimateProductsToEstimates, this runs in the calling transaction and
// returns the created estimate product instance details immediately.
List<ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesSyncResponse> responses = ffscpq.AddEstimateProductService.addEstimateProductsToEstimatesSync(
    new List<ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequest>{ request }
);

// Extract the response data
System.debug('The estimate product ID: ' + responses[0].EstimateProductId);
System.debug('The destination estimate ID: ' + responses[0].EstimateId);

// The new estimate product instance was created within this transaction.
System.debug('Created: ' + responses[0].Success);
System.debug('The estimate product instance ID: ' + responses[0].EstimateProductInstanceId);
System.debug('The estimate product instance name: ' + responses[0].EstimateProductInstanceName);

ffscpq.AddEstimateProductService.IFinalizeEstimateAction

global interface IFinalizeEstimateAction

An action that is executed after all estimate products have been added to an estimate. The action runs inline in the same transaction that enqueues the async rollup, so field values on the estimate reflect pre-rollup state.
To execute after rollup values are committed, implement IDeferrableFinalizeEstimateAction instead. That interface adds getCallableClassName() and serializeState() methods, enabling the action to be deferred until the asynchronous rollup completes. The deferred action executes inside the rollup completion callback, where all rolled-up field values (hours, amounts, estimate totals) are fully committed to the database.

Methods

execute

void execute(Id estimateId)

ffscpq.AddEstimateProductService.IDeferrableFinalizeEstimateAction

global interface IDeferrableFinalizeEstimateAction extends IFinalizeEstimateAction

An extension of IFinalizeEstimateAction that can be deferred until after an asynchronous rollup completes. Implementations return a Callable class name and serialised state; the rollup completion callback reconstitutes and executes the action once rollup values are committed to the database.
The Callable class receives two arguments: 'destinationEstimateId' (Id) and 'finalizerState' (String, the value returned by serializeState()). Exceptions thrown by the Callable will prevent the process lock from being released.
Upgrade path: implement this interface on the existing IFinalizeEstimateAction class. getCallableClassName() should return the fully qualified name of a global System.Callable class (use MyCallable.class.getName() to ensure correctness, including namespace prefix for managed package classes). serializeState() should return a JSON string capturing any state needed by the Callable. The execute(Id) method is skipped when the action is deferred.
Error handling:
- If the rollup fails, the deferred finalizer does not execute.
- If Type.forName cannot resolve the Callable class name, the finalizer is silently skipped.
- If the Callable throws an unhandled exception, the process lock (Services_CPQ_Process_Lock__c) is not released and must be manually deleted.

This class extends ffscpq.AddEstimateProductService.IFinalizeEstimateAction

Methods

getCallableClassName

String getCallableClassName()

serializeState

String serializeState()

ffscpq.AddEstimateProductService.IFinalizeEstimateProductAction

global interface IFinalizeEstimateProductAction

An action that is executed after the estimate product has been added to the estimate.

Methods

execute

void execute(ffscpq__Estimate_Product_Instance__c estimateProductInstance)

ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequest

global with sharing class AddEstimateProductsToEstimatesRequest

The request structure for adding an estimate product to an estimate.

Properties

Name Type Description
EstimateId Id The estimate to copy the estimate product to.
EstimateProductId Id The estimate product to be copied.
EstimateProductItemIds List<Id> The list of estimate product items to be copied. If no IDs are provided, only default estimate product items are copied.
EstimateProductInstanceBillingType String [Optional] The billing type for the copied estimate product instance. Must be 'Fixed Price' or 'Time and Materials'. If this is not provided the estimate product's default billing type is used.
EstimateProductInstanceFixedPriceMargin Decimal [Optional] The fixed price margin for the copied estimate product instance. If this is not provided and the billing type is 'Fixed Price', the estimate product's default fixed price margin is used. If the billing type is 'Time and Materials', this parameter is not used.
EstimateProductInstancePaymentTerms Id [Optional] The payment terms that relate to the estimate product instance. If they are not provided, the estimate product's default payment terms are applied. To clear this field on the resulting estimate product instance rather than inheriting the default value, supply a null entry for this field via FieldOverridesByType keyed on Estimate_Product_Instance__c.SObjectType.
Name String [Optional] The name for the copied estimate product instance. If this is not provided the estimate product's name is used.
StartDate Date [Optional] The start date of the copied estimate product instance will be offset relative to this date. If this is not provided the estimate's start date is used.
CurrencyIsoCode String [Optional] The currency of the copied estimate product instance. If this is not provided the estimate's currency is used.
EstimateProductInstanceFixedPriceBillingFrequency String [Optional] The fixed price billing frequency of the copied estimate product instance. If this is not provided the Line Set End Date is used.
EstimateProductInstanceFixedPriceUpfrontBillingPercent Decimal [Optional] The fixed price up front billing percent of the copied estimate product instance. If this is not provided, 0 is used.
FinalizeEstimateAction ffscpq.AddEstimateProductService.IFinalizeEstimateAction [Optional] An action to be executed after all estimate products have been added to an estimate.
FinalizeAction ffscpq.AddEstimateProductService.IFinalizeEstimateProductAction [Optional] An action to be executed after the estimate product has been added to the estimate.
FieldOverridesByType Map<SObjectType, Map<SObjectField, Object>> [Optional] The specified object fields will be overridden to the supplied values. Supported Objects: ffscpq__Estimate_Product_Instance__c 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 ffscpq__Services_Product_Instance__c ffscpq__Estimate_Pricing_Modifier_Instance__c
--- Unsupported Fields: CurrencyIsoCode ffscpq__Start_Date__c ffscpq__End_Date__c ffscpq__Original_Hours__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
EstimatePricingMethodId Id [Optional] The estimate pricing method for the copied estimate product instance. If this is not provided, the value is inherited from the Estimate Product. To clear this field on the resulting estimate product instance rather than inheriting the default value, supply a null entry for this field via FieldOverridesByType keyed on Estimate_Product_Instance__c.SObjectType.

Methods

AddEstimateProductsToEstimatesRequest

global AddEstimateProductsToEstimatesRequest(Id estimateId, Id estimateProductId)

A default constructor with minimum required properties.

Input Parameters

Name Type Description
estimateId Id The ID of the estimate.
estimateProductId Id The ID of the estimate product.

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 add the estimate product to.
Id estimateId = 'a6MDK000000L2fJ2AS';

// The ID of the estimate product that you want to add to the estimate.
Id estimateProductId = 'a6HDK000000L2uu2AC';

// Construct the request
ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequest request = new ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequest(
    estimateId,
    estimateProductId
);

// You can optionally set the billing type to change from the estimate product default.
request.EstimateProductInstanceBillingType = 'Fixed Price';

// You can optionally set the fixed price billing frequency to change from the estimate product default.
request.EstimateProductInstanceFixedPriceBillingFrequency = 'Line Set End Date';

// You can optionally set the fixed price upfront billing percent to change from the estimate product default.
request.EstimateProductInstanceFixedPriceUpfrontBillingPercent = 50;

// If billing type is specified as Fixed Price or you want to change from the default fixed price margin, you can set it here.
request.EstimateProductInstanceFixedPriceMargin = 15;

// You can optionally set the name of the created estimate product instance.
request.Name = 'Delivery & Support';

// You can optionally set the start date of the created estimate product instance if you want it offset from the target estimate start date.
request.StartDate = Date.newInstance(2023, 1, 1);

// You can optionally set the payment terms to change from the estimate product default.
request.EstimateProductInstancePaymentTerms = 'a5bEc000002GzXqIAK';

// You can optionally specify which estimate product items to copy. If not provided, only items
// where Default is true are copied.
request.EstimateProductItemIds = new List<Id>{ 'a7xDK000000L2uu2AC', 'a7xDK000000L2uv2AC' };

// 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.AddEstimateProductService.AddEstimateProductsToEstimatesResponse

global with sharing class AddEstimateProductsToEstimatesResponse

The result returned after adding an estimate product to an estimate.

Properties

Name Type Description
EstimateProductId Id The estimate product that was added.
EstimateId Id The estimate which the estimate product was added to.
JobId Id The AsyncApexJob Id.
Errors List<ffscpq.AddEstimateProductService.AddEstimateProductError> A list containing errors that occurred while processing the request.

ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesSyncResponse

global with sharing class AddEstimateProductsToEstimatesSyncResponse

The result returned for each request from addEstimateProductsToEstimatesSync.

Properties

Name Type Description
EstimateProductId Id The estimate product that was requested.
EstimateId Id The estimate the product was added to.
EstimateProductInstanceId Id The ID of the newly created estimate product instance, if successful.
EstimateProductInstanceName String The name of the newly created estimate product instance, if successful.
Errors List<ffscpq.AddEstimateProductService.AddEstimateProductError> A list containing errors that occurred while processing the request.

ffscpq.AddEstimateProductService.AddEstimateProductError

global with sharing class AddEstimateProductError

The error that occurred while processing the request.

Properties

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