Services CPQ API Developer Reference

ffscpq.AddToProjectFromEstimateService

global with sharing class AddToProjectFromEstimateService

A service that provides functionality related to adding estimate records to a project. The service will also add estimate records to their related opportunities.

Methods

addToProjectsFromEstimatesAsync

global static List<ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncResponse> addToProjectsFromEstimatesAsync(List<ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequest> requests)

A method that adds estimate records to a project. The method will also add records from the estimates to the related opportunities.

Input Parameters

Name Type Description
requests List<ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequest> The list of AddToProjectFromEstimateAsyncRequest objects.

Return Value

This service returns AddToProjectFromEstimateAsyncResponse 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 contains the records you want to add to a project. A request is required for each project you want to add to.
Id estimateId = 'a6B5C0000004VrnUAE';

// The ID of the project you want to add to. It must be associated with the same opportunity as the estimate and in the same currency as the estimate products being added.
Id projectId = 'a2W6s000000pjyTEAQ';

// Provide the request with the estimate product IDs that you want to add to a project.
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.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequest request = new ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequest(
    estimateId,
    projectId
);
request.EstimateProductIds = estimateProductInstanceIds;

// You can optionally disable records independent of estimate products so that they are not included in the project.
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_Role_Request__c.Test__c',
    'ffscpq__Estimate_Role_Request__c.ffscpq__Estimate_Task__r.Custom_Field__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.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncResponse> responses = ffscpq.AddToProjectFromEstimateService.addToProjectsFromEstimatesAsync(
    new List<ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequest>{ request }
);

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

// 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.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequest

global with sharing class AddToProjectFromEstimateAsyncRequest

The request structure for adding estimate records to a project.

Properties

Name Type Description
EstimateId Id The ID of the estimate to add records from.
ProjectId Id The ID of the project to add estimate records to.
EstimateProductIds Set<Id> A set of IDs of the estimate product instances to be added to the project.
IncludeRecordsIndependentOfEstimateProducts Boolean If true, records independent of estimate products will be added to the project.
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

AddToProjectFromEstimateAsyncRequest

global AddToProjectFromEstimateAsyncRequest(Id estimateId, Id projectId)

Input Parameters

Name Type Description
estimateId Id The ID of the estimate
projectId Id The ID of the project

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 contains the records you want to add to a project. A request is required for each project you want to add to.
Id estimateId = 'a6B5C0000004VrnUAE';

// The ID of the project you want to add to. It must be associated with the same opportunity as the estimate and in the same currency as the estimate products being added.
Id projectId = 'a2W6s000000pjyTEAQ';

// Provide the request with the estimate product IDs that you want to add to a project.
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.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequest request = new ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncRequest(
    estimateId,
    projectId
);
request.EstimateProductIds = estimateProductInstanceIds;

// You can optionally disable records independent of estimate products so that they are not included in the project.
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_Role_Request__c.Test__c',
    'ffscpq__Estimate_Role_Request__c.ffscpq__Estimate_Task__r.Custom_Field__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.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncResponse

global with sharing class AddToProjectFromEstimateAsyncResponse

The response structure for adding estimate records to a project.

Properties

Name Type Description
EstimateId Id The ID of the estimate to add records from.
ProjectId Id The ID of the project to add estimate records to.
Errors List<ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncError> A list containing errors that occurred while processing the request.

ffscpq.AddToProjectFromEstimateService.AddToProjectFromEstimateAsyncError

global with sharing class AddToProjectFromEstimateAsyncError

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.