Services CPQ API Developer Reference

ffscpq.PushToOpportunityService

global with sharing class PushToOpportunityService

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

Methods

pushToOpportunity

global static List<ffscpq.PushToOpportunityService.PushToOpportunityResponse> pushToOpportunity(List<ffscpq.PushToOpportunityService.PushToOpportunityRequest> requests)

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

Input Parameters

Name Type Description
requests List<ffscpq.PushToOpportunityService.PushToOpportunityRequest> The list of PushToOpportunityRequest objects.

Return Value

This service returns PushToOpportunityResponse 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 push to the related opportunity. A request is required for each estimate you want to push.
Id estimateId = 'a6B5C0000004VrnUAE';

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

// This is an optional setting that provides additional fields to consolidate estimate role requests by when generating resource requests.
request.AdditionalAggregationFields = new Set<SObjectField>{
    ffscpq__Estimate_Role_Request__c.ffscpq__Test__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 details for the product used to represent estimate records that are independent of estimate products.
request.ProductId = '01t5C000006gCveQAE';
request.ProductDate = Date.today();
request.ProductDescription = 'A description';

ffscpq.PushToOpportunityService.pushToOpportunity(
    new List<ffscpq.PushToOpportunityService.PushToOpportunityRequest>{ request }
);

ffscpq.PushToOpportunityService.PushToOpportunityRequest

global with sharing class PushToOpportunityRequest

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

Properties

Name Type Description
EstimateId Id The ID of the estimate being pushed.
EstimateProductIds Set<Id> A set of IDs of the estimate product instances to be pushed.
IncludeRecordsIndependentOfEstimateProducts Boolean If true, records independent of estimate products will be pushed.
AdditionalAggregationFields Set<SObjectField> [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.
ProductId Id The ID of the product used to represent records that are independent of estimate products.
ProductDate Date The date of the opportunity product used to represent records that are independent of estimate products.
ProductDescription String The description of the opportunity product used to represent records that are independent of estimate products.

Methods

PushToOpportunityRequest

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

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

// This is an optional setting that provides additional fields to consolidate estimate role requests by when generating resource requests.
request.AdditionalAggregationFields = new Set<SObjectField>{
    ffscpq__Estimate_Role_Request__c.ffscpq__Test__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 details for the product used to represent estimate records that are independent of estimate products.
request.ProductId = '01t5C000006gCveQAE';
request.ProductDate = Date.today();
request.ProductDescription = 'A description';

ffscpq.PushToOpportunityService.PushToOpportunityResponse

global with sharing class PushToOpportunityResponse

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

© Copyright 2009–2023 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.