Professional Services Automation Apex API Developer Reference

pse.RevenueForecastService

global with sharing class RevenueForecastService

This service provides the functionality relating to revenue forecasts.

Methods

runForOpportunitiesAsync

global static pse.RevenueForecastService.RunForOpportunitiesAsyncResponse runForOpportunitiesAsync(pse.RevenueForecastService.RunForOpportunitiesAsyncRequest request)

Enqueues the Revenue Forecast Apex job to asynchronously process opportunities marked as Revenue Forecast Batch Update Pending. If opportunity IDs are provided, it will mark those opportunities as Revenue Forecast Batch Update Pending before scheduling the Apex job.

Input Parameters

Name Type Description
request pse.RevenueForecastService.RunForOpportunitiesAsyncRequest The configuration for the operation.

Return Value

The result of the operation.

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.

Opportunity[] opportunities = [SELECT Id FROM Opportunity LIMIT 10];
Set<Id> opportunityIds = new Map<Id, SObject>(opportunities).keySet();
pse.RevenueForecastService.RunForOpportunitiesAsyncRequest request = new pse.RevenueForecastService.RunForOpportunitiesAsyncRequest( opportunityIds );
pse.RevenueForecastService.RunForOpportunitiesAsyncResponse response = pse.RevenueForecastVersionService.runForOpportunitiesAsync(request);

for (Opportunity opportunityRecord : opportunities) {
    Boolean success = response.getSuccess(opportunityRecord.Id);
}

runForProjectsAsync

global static pse.RevenueForecastService.RunForProjectsAsyncResponse runForProjectsAsync(pse.RevenueForecastService.RunForProjectsAsyncRequest request)

Enqueues the Revenue Forecast Apex job to asynchronously process projects marked as Revenue Forecast Batch Update Pending. If project IDs are provided, it will mark those projects as Revenue Forecast Batch Update Pending before scheduling the Apex job.

Input Parameters

Name Type Description
request pse.RevenueForecastService.RunForProjectsAsyncRequest The configuration for the operation.

Return Value

The result of the operation.

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.

pse__Proj__c[] projects = [SELECT Id FROM pse__Proj__c LIMIT 10];
Set<Id> projectIds = new Map<Id, SObject>(projects).keySet();
pse.RevenueForecastService.RunForProjectsAsyncRequest request = new pse.RevenueForecastService.RunForProjectsAsyncRequest( projectIds );
pse.RevenueForecastService.RunForProjectsAsyncResponse response = pse.RevenueForecastVersionService.runForProjectsAsync(request);

for (pse__Proj__c project : projects) {
    Boolean success = response.getSuccess(project.Id);
}

pse.RevenueForecastService.RunForOpportunitiesAsyncRequest

global with sharing class RunForOpportunitiesAsyncRequest

The request structure for creating revenue forecasts for opportunities.

Properties

Name Type Description
OpportunityIds Set<Id> The opportunity IDs to be forecasted. If empty, all opportunities pending an update will be forecasted.

Methods

RunForOpportunitiesAsyncRequest

global RunForOpportunitiesAsyncRequest()

A constructor that creates a new RunForOpportunitiesAsyncRequest instance.

RunForOpportunitiesAsyncRequest

global RunForOpportunitiesAsyncRequest(Set<Id> opportunityIds)

A constructor that creates a new RunForOpportunitiesAsyncRequest instance.

Input Parameters

Name Type Description
opportunityIds Set<Id> The opportunity IDs to be forecasted.

pse.RevenueForecastService.RunForOpportunitiesAsyncResponse

global with sharing class RunForOpportunitiesAsyncResponse

The response structure from creating revenue forecasts for opportunities.

Properties

Name Type Description
ErrorsByOpportunityId Map<Id, List<String>> A map of the errors returned by the forecast run, keyed by Opportunity ID
IsUsingUnsupportedRevManVersion Boolean Whether a supported version of Revenue Management is in use

Methods

RunForOpportunitiesAsyncResponse

global RunForOpportunitiesAsyncResponse()

A constructor that creates a new RunForOpportunitiesAsyncResponse instance.

getSuccess

global Boolean getSuccess(Id opportunityId)

Indicates whether the given opportunity was successfully marked as Revenue Forecast Batch Update Pending.

Input Parameters

Name Type Description
opportunityId Id The opportunity ID.

Return Value

True if the forecast was successfully created for a given opportunity ID.

getErrors

global List<String> getErrors(Id opportunityId)

Lists the errors encountered while marking the given opportunity as Revenue Forecast Batch Update Pending.

Input Parameters

Name Type Description
opportunityId Id The opportunity ID.

Return Value

The list of errors for the given opportunity ID.

getAllErrorsByOpportunityId

global Map<Id, List<String>> getAllErrorsByOpportunityId()

Lists the errors encountered while marking the given opportunities as Revenue Forecast Batch Update Pending and enqueuing the Revenue Forecast Apex job.

Return Value

The list of errors for the given Opportunity ID.

pse.RevenueForecastService.RunForProjectsAsyncRequest

global with sharing class RunForProjectsAsyncRequest

The request structure for creating revenue forecasts for projects.

Properties

Name Type Description
ProjectIds Set<Id> The project IDs to be forecasted. If empty, all pending projects will be processed.

Methods

RunForProjectsAsyncRequest

global RunForProjectsAsyncRequest()

A constructor that creates a new RunForProjectsAsyncRequest instance.

RunForProjectsAsyncRequest

global RunForProjectsAsyncRequest(Set<Id> projectIds)

A constructor that creates a new RunForProjectsAsyncRequest instance.

Input Parameters

Name Type Description
projectIds Set<Id> The project IDs to be forecasted.

pse.RevenueForecastService.RunForProjectsAsyncResponse

global with sharing class RunForProjectsAsyncResponse

The response structure from creating revenue forecasts for projects.

Properties

Name Type Description
ErrorsByProjectId Map<Id, List<String>> A map of the errors returned by the forecast run, keyed by Opportunity ID
IsUsingUnsupportedRevManVersion Boolean Whether a supported version of Revenue Management is in use

Methods

RunForProjectsAsyncResponse

global RunForProjectsAsyncResponse()

A constructor that creates a new RunForProjectsAsyncResponse instance.

RunForProjectsAsyncResponse

global RunForProjectsAsyncResponse(Map<Id, List<String>> errorsByProjectId, Boolean usingUnsupportedRevManVersion)

A constructor that creates a new RunForProjectsAsyncResponse instance.

getSuccess

global Boolean getSuccess(Id projectId)

Indicates whether the given project was successfully marked as Revenue Forecast Batch Update Pending.

Input Parameters

Name Type Description
projectId Id The project ID.

Return Value

True if the forecast was successfully created for a given project ID.

getErrors

global List<String> getErrors(Id projectId)

Lists the errors encountered while marking the given project as Revenue Forecast Batch Update Pending.

Input Parameters

Name Type Description
projectId Id The project ID.

Return Value

The list of errors for the given project ID.

getAllErrorsByProjectId

global Map<Id, List<String>> getAllErrorsByProjectId()

Lists the errors encountered while marking the given projects as Revenue Forecast Batch Update Pending and enqueuing the Revenue Forecast Apex job.

Return Value

The list of errors for the given project ID.

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