Services CPQ API Developer Reference

ffscpq.AddToOpportunityFromEstimatePlugin

global with sharing class AddToOpportunityFromEstimatePlugin

A class that contains plugins to use after the adding to opportunity action has been completed.

ffscpq.AddToOpportunityFromEstimatePlugin.IAddToOpportunityFromEstimatePlugin

global interface IAddToOpportunityFromEstimatePlugin

Provides an interface that can be used to create plugins to be executed after the Add to Opportunity action is complete. This enables the custom Apex classes to be executed. To set up a plugin, create a fferpcore__Plugin__mdt record with a fferpcore__ExtensionPoint__c of AddToOpportunityFromEstimatePlugin.IAddToOpportunityFromEstimatePlugin, and a ClassName that matches an Apex class which implements that interface.

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.

/**
 * This Add to Opportunity From Estimate plugin example uses the Add_From_Estimate_Timestamp__c custom date/time field on the Opportunity object.
 * It indicates the most recent time that records were added to opportunity from an estimate.
 */
public with sharing class AddToOpportunityTimestampPlugin implements ffscpq.AddToOpportunityFromEstimatePlugin.IAddToOpportunityFromEstimatePlugin {
    public ffscpq.AddToOpportunityFromEstimatePlugin.Response executePlugin(
        ffscpq.AddToOpportunityFromEstimatePlugin.Request request
    ) {
        /**
         * The resulting data is retrieved from the estimate product instances used in the Add to Opportunity action which executed this plugin.
         * // The IDs of the estimates related to these estimate product instances are then stored in a set.
         */
        List<ffscpq.AddToOpportunityFromEstimatePlugin.Result> results = request.getResults();
        Set<Id> estimateIds = new Set<Id>();
        Set<Id> opportunityIds = new Set<Id>();

        for (ffscpq.AddToOpportunityFromEstimatePlugin.Result result : results) {
            // Only the data of successfully processed estimate product instances are used.
            if (result.getStatus() == ffscpq.EstimateActionStatus.SUCCESSFUL) {
                estimateIds.add(result.getEstimateId());
            }
        }

        // Select an opporunity ID from an estimate, and use this field to populate the opportunityIds set.
        List<ffscpq__Estimate__c> estimates = [
            SELECT Id, ffscpq__Opportunity__c
            FROM ffscpq__Estimate__c
            WHERE Id IN :estimateIds
        ];

        for (ffscpq__Estimate__c estimate : estimates) {
            opportunityIds.add(estimate.ffscpq__Opportunity__c);
        }

        // Select the Add_From_Estimate_Timestamp__c field on the opportunity related to the estimate. Retrieve the time and date from the org and add it to the Add_From_Estimate_Timestamp__c field.
        List<Opportunity> opportunities = [
            SELECT Id, Add_From_Estimate_Timestamp__c
            FROM Opportunity
            WHERE Id IN :opportunityIds
        ];

        for (Opportunity opportunity : opportunities) {
            opportunity.Add_From_Estimate_Timestamp__c = Datetime.now();
        }

        update opportunities;

        // Create the response.
        return buildResponse(request);
    }

    private ffscpq.AddToOpportunityFromEstimatePlugin.Response buildResponse(
        ffscpq.AddToOpportunityFromEstimatePlugin.Request request
    ) {
        ffscpq.AddToOpportunityFromEstimatePlugin.Response response = new ffscpq.AddToOpportunityFromEstimatePlugin.Response();

        response.setRequest(request);

        return response;
    }
}

Methods

executePlugin

Response executePlugin(ffscpq.AddToOpportunityFromEstimatePlugin.Request request)

A method that executes this plugin implementation.

Input Parameters

Name Type Description
request ffscpq.AddToOpportunityFromEstimatePlugin.Request A request.

Return Value

A response that parallels the request.

ffscpq.AddToOpportunityFromEstimatePlugin.Request

global with sharing class Request

The request structure for executing the plugin.

Methods

getResults

global List<ffscpq.AddToOpportunityFromEstimatePlugin.Result> getResults()

Retrieves a list that contains the response data of the estimate product instances used in the Add to Opportunity action that executed this plugin.

Return Value

A list of Results.

getAdditionalAggregationFieldPaths

global List<String> getAdditionalAggregationFieldPaths()

Retrieves a string field path of additional fields used to consolidate role requests when creating resource requests.

Return Value

A list of String field paths used in role request consolidation.

isAggregatedBySkills

global Boolean isAggregatedBySkills()

Indicates whether the role requests that were added to opportunity were consolidated by skills.

Return Value

A boolean to indicate if role requests were consolidated by skills.

ffscpq.AddToOpportunityFromEstimatePlugin.Result

global with sharing class Result

Result containing data of the estimate product instance used in the Add to Opportunity action that executes this plugin.

Methods

getEstimateId

global Id getEstimateId()

The ID of the estimate used in the Add to Opportunity action which executed this plugin.

Return Value

The ID of the estimate associated with the estimate product instances.

getEstimateProductInstanceId

global Id getEstimateProductInstanceId()

The ID of the estimate product instance used in the Add to Opportunity action which executed this plugin.

Return Value

The ID of the estimate product instance.

getStatus

global ffscpq.EstimateActionStatus getStatus()

The ffscpq.EstimateActionStatus enum that corresponds to the status of the Add to Opportunity action which executed this plugin.

Return Value

An EstimateActionStatus.

getErrors

global List<ffscpq.AddToOpportunityFromEstimatePlugin.Error> getErrors()

A list containing errors that resulted from the Add to Opportunity action which executed this plugin.

Return Value

A list of errors.

ffscpq.AddToOpportunityFromEstimatePlugin.Response

global with sharing class Response

The response structure for executing the plugin.

Methods

Response

global Response()

setRequest

global void setRequest(ffscpq.AddToOpportunityFromEstimatePlugin.Request sourceRequest)

Set the source request used by this plugin.

Input Parameters

Name Type Description
sourceRequest ffscpq.AddToOpportunityFromEstimatePlugin.Request - The source request used by this plugin.

getRequest

global ffscpq.AddToOpportunityFromEstimatePlugin.Request getRequest()

Retrieves the source request used by this plugin.

Return Value

A request.

ffscpq.AddToOpportunityFromEstimatePlugin.Error

global with sharing class Error

The structure of the errors that occurred during the Add to Opportunity action which executed this plugin.

Methods

getMessage

global String getMessage()

The message of the error that occured during the Add to Opportunity action which executed this plugin.

Return Value

A string error message.

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