Services CPQ API Developer Reference

ffscpq.AddToOpportunityFromEstimateService

global with sharing class AddToOpportunityFromEstimateService

A service that provides functionality related to adding details from estimates to their related opportunities.

Methods

addToOpportunitiesFromEstimatesAsync

global static List<ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncResponse> addToOpportunitiesFromEstimatesAsync(List<ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequest> requests)

A method that adds estimate details to their related opportunities by creating resource requests and opportunity products.

Input Parameters

Name Type Description
requests List<ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequest> The list of AddToOpportunityFromEstimateAsyncRequest objects.

Return Value

This service returns AddToOpportunityFromEstimateAsyncResponse 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 primary estimate that contains the details you want to add to the related opportunity. A request is required for each estimate you want to add to opportunity.
Id estimateId = 'a6B5C0000004VrnUAE';

// Provide the request with the estimate product IDs that you want to add details from. If you want to add 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.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequest request = new ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequest(
    estimateId
);
request.EstimateProductIds = estimateProductInstanceIds;

// You can optionally disable records independent of estimate products so that they are not included.
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__Estimate_Task__r.Name',
    'ffscpq__Region__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.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncResponse> responses = ffscpq.AddToOpportunityFromEstimateService.addToOpportunitiesFromEstimatesAsync(
    new List<ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequest>{
        request
    }
);

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

// Extract errors
System.debug('Number of errors: ' + responses[0].Errors.size());

for (
    ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncError error : responses[0]
        .Errors
) {
    System.debug(error.Message);
}

ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequest

global with sharing class AddToOpportunityFromEstimateAsyncRequest

The request structure for adding an estimate to its related opportunity.

Properties

Name Type Description
EstimateId Id The ID of the estimate being added to opportunity.
EstimateProductIds Set<Id> A set of IDs of the estimate product instances to be added to opportunity.
IncludeRecordsIndependentOfEstimateProducts Boolean If true, records independent of estimate products will be added to opportunity.
AdditionalAggregationFieldPaths List<String> [Optional] Additional fields to consolidate estimate role requests by when creating resource requests.
AggregateBySkills Boolean If true, role requests are consolidated by skills. The default value is false.
CreateOpportunityLineItems Boolean If true, opportunity products are created for each estimate product instance. The default value is true.

Methods

AddToOpportunityFromEstimateAsyncRequest

global AddToOpportunityFromEstimateAsyncRequest(Id estimateId)

A default constructor with minimum required properties.

Input Parameters

Name Type Description
estimateId Id The estimate ID.

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 primary estimate that contains the details you want to add to the related opportunity. A request is required for each estimate you want to add to opportunity.
Id estimateId = 'a6B5C0000004VrnUAE';

// Provide the request with the estimate product IDs that you want to add details from. If you want to add 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.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequest request = new ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncRequest(
    estimateId
);
request.EstimateProductIds = estimateProductInstanceIds;

// You can optionally disable records independent of estimate products so that they are not included.
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__Estimate_Task__r.Name',
    'ffscpq__Region__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.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncResponse

global with sharing class AddToOpportunityFromEstimateAsyncResponse

The response structure for adding an estimate to its related opportunity.

Properties

Name Type Description
EstimateId Id The estimate ID.
Errors List<ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncError> A list containing errors that occurred while processing the request.

ffscpq.AddToOpportunityFromEstimateService.AddToOpportunityFromEstimateAsyncError

global with sharing class AddToOpportunityFromEstimateAsyncError

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.