ffscpq.AddEstimateProductServiceglobal with sharing class AddEstimateProductService A service that provides functionality related to adding estimate products to estimates. Methods
addEstimateProductsToEstimatesglobal static List<ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesResponse> addEstimateProductsToEstimates(List<ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequest> requests) A method that adds estimate products to estimates. Input Parameters
Return ValueThis 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);
}
addEstimateProductsToEstimatesSyncglobal static List<ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesSyncResponse> addEstimateProductsToEstimatesSync(List<ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequest> requests) A method that synchronously adds estimate products to estimates. Input Parameters
Return ValueAddEstimateProductsToEstimatesSyncResponse 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.IFinalizeEstimateActionglobal 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. Methodsexecutevoid execute(Id estimateId) ffscpq.AddEstimateProductService.IDeferrableFinalizeEstimateActionglobal 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. This class extends ffscpq.AddEstimateProductService.IFinalizeEstimateAction MethodsgetCallableClassNameString getCallableClassName() serializeStateString serializeState() ffscpq.AddEstimateProductService.IFinalizeEstimateProductActionglobal interface IFinalizeEstimateProductAction An action that is executed after the estimate product has been added to the estimate. Methodsexecutevoid execute(ffscpq__Estimate_Product_Instance__c estimateProductInstance) ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesRequestglobal with sharing class AddEstimateProductsToEstimatesRequest The request structure for adding an estimate product to an estimate. Properties
MethodsAddEstimateProductsToEstimatesRequestglobal AddEstimateProductsToEstimatesRequest(Id estimateId, Id estimateProductId) 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 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.AddEstimateProductsToEstimatesResponseglobal with sharing class AddEstimateProductsToEstimatesResponse The result returned after adding an estimate product to an estimate. Properties
ffscpq.AddEstimateProductService.AddEstimateProductsToEstimatesSyncResponseglobal with sharing class AddEstimateProductsToEstimatesSyncResponse The result returned for each request from addEstimateProductsToEstimatesSync. Properties
ffscpq.AddEstimateProductService.AddEstimateProductErrorglobal with sharing class AddEstimateProductError The error that occurred while processing the request. Properties
|