Services CPQ API Developer Reference

ffscpq.CreateProjectFromEstimateService

global with sharing class CreateProjectFromEstimateService

A service that provides functionality related to creating projects from estimate details. The service will also add estimate details to their related opportunities.

Methods

createProjectsFromEstimatesAsync

global static List<ffscpq.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncResponse> createProjectsFromEstimatesAsync(List<ffscpq.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncRequest> requests)

A method that creates projects from estimate details. The method will also add details from the estimates to the related opportunities.

Input Parameters

Name Type Description
requests List<ffscpq.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncRequest> The list of CreateProjectFromEstimateAsyncRequest objects.

Return Value

This service returns CreateProjectFromEstimateAsyncResponse 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 details you want to create a project from. A request is required for each project you want to create.
Id estimateId = 'a6B5C0000004VrnUAE';

// Provide the request with details of the project to be created.
pse__Proj__c project = new pse__Proj__c(
    Name = 'My Project',
    pse__Region__c = 'a2y7e0000017KIqAAM',
    pse__Start_Date__c = Date.newInstance(2022, 1, 1),
    CurrencyIsoCode = 'USD'
);

// Provide the request with the estimate product IDs that you want to create a project from. If you want to create a project using 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.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncRequest request = new ffscpq.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncRequest(
    estimateId,
    project
);
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__Test__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.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncResponse> responses = ffscpq.CreateProjectFromEstimateService.createProjectsFromEstimatesAsync(
    new List<ffscpq.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncRequest>{
        request
    }
);

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

global with sharing class CreateProjectFromEstimateAsyncRequest

The request structure for creating a project from an estimate.

Properties

Name Type Description
EstimateId Id The ID of the estimate to create the project from.
ProjectDetails pse__Proj__c A project record with the specified values for the new project.
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

CreateProjectFromEstimateAsyncRequest

global CreateProjectFromEstimateAsyncRequest(Id estimateId, pse__Proj__c projectDetails)

Input Parameters

Name Type Description
estimateId Id The ID of the estimate
projectDetails pse__Proj__c Contains data for the new 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 details you want to create a project from. A request is required for each project you want to create.
Id estimateId = 'a6B5C0000004VrnUAE';

// The field values for the project to be created.
pse__Proj__c project = new pse__Proj__c(
    Name = 'My Project',
    pse__Region__c = 'a2y7e0000017KIqAAM',
    pse__Start_Date__c = Date.newInstance(2022, 1, 1)
);

// Provide the request with the estimate product IDs that you want to create a project from. If you want to create a project using 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.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncRequest request = new ffscpq.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncRequest(
    estimateId,
    project
);
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.AdditionalAggregationFields = new Set<String>{
    'ffscpq__Test__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.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncResponse

global with sharing class CreateProjectFromEstimateAsyncResponse

The response structure for creating a project from an estimate.

Properties

Name Type Description
EstimateId Id The estimate ID.
ProjectId Id The ID of the created project.
Errors List<ffscpq.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncError> A list containing errors that occurred while processing the request.

ffscpq.CreateProjectFromEstimateService.CreateProjectFromEstimateAsyncError

global with sharing class CreateProjectFromEstimateAsyncError

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.