Revenue Management API Developer Reference

ffrr.RevenueContractService

global with sharing class RevenueContractService

Methods

populateFromSourceRecords

global static ffrr.RevenueContractService.PopulateResult populateFromSourceRecords(ffrr.RevenueContractService.PopulateContext context)

Will update the Performance Obligation Line Items that can be found linking to the given source records, and in turn the Performance Obligation from the controlling Performance Obligation Line Item.
NB This uses a noticeable amount of SOQL queries, and as such should not be used where a trigger may be handling more than 1000 records. CPU time, which must be 'shared' with the calling process, may reduce that further in practice.
This currently requires both sharing and CRUD access to the Performance Obligation Line Items and Performance Obligation as well as the ability to read Settings and FieldMappings.

Input Parameters

Name Type Description
context ffrr.RevenueContractService.PopulateContext A RevenueContractService.PopulateContext object containing the source IDs to repopulate from.

Return Value

A RevenueContractService.PopulateResult that contains the Ids of the updated Performance Obligation Line Items and any updated Performance obligations.

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.

// In this example the Revenue Contract Service is used to update
// any existing Performance Obligation Line Items based on the source records
// which in this case are assumed to be the Opportunities (from an Opportunity trigger).


trigger UpdatePOLI on Opportunity (after update) 
{
    ffrr.RevenueContractService.PopulateContext context = new ffrr.RevenueContractService.PopulateContext();

    for(SObject obj: Trigger.New)
    {
        context.SourceRecordIDs.add(obj.ID);
    }

    ffrr.RevenueContractService.populateFromSourceRecords( context );
}

populateFromSourceRecordsAsync

global static ID populateFromSourceRecordsAsync(ffrr.RevenueContractService.PopulateContext context)

This will start a queuable job to update Performance Obligation Line Items based on the source records indicated. The work done will be the same as populateFromSourceRecords, except that it happens via a queuable. The aysnc nature does mean that triggers that call this will not see any errors that occur during the populate.

Input Parameters

Name Type Description
context ffrr.RevenueContractService.PopulateContext A RevenueContractService.PopulateContext object containing the source IDs to repopulate from.

Return Value

The id of the queued job.

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.

// In this example the Revenue Contract Service is used to update
// any existing Performance Obligation Line Items based on the source records
// which in this case are assumed to be the Opportunities (from an Opportunity trigger).
// Calling the Async version will set off a queuable job to do the work, so the
// trigger is not affected by the update, but neither can it react to any failures to
// update the Performance Obligation Line Items.


trigger UpdatePOLI on Opportunity (after update) 
{
    ffrr.RevenueContractService.PopulateContext context = new ffrr.RevenueContractService.PopulateContext();

    for(SObject obj: Trigger.New)
    {
        context.SourceRecordIDs.add(obj.ID);
    }

    ffrr.RevenueContractService.populateFromSourceRecordsAsync( context );
}

reallocate

global static void reallocate(List<Id> contractIds)

Calculates the Allocated Revenue for the Performance Obligation records related to the Revenue Contracts provided.

Input Parameters

Name Type Description
contractIds List<Id> The list of Revenue Contract IDs.

retrieve

global static List<ffrr.RevenueContractService.RevenueContract> retrieve(List<Id> contractIds)

Retrieves a list of RevenueContract records based on their IDs.

Input Parameters

Name Type Description
contractIds List<Id> A list of the IDs of RevenueContracts to retrieve.

Return Value

A list of RevenueContract objects

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.

// In this example the Revenue Contract Service is used to retrieve existing
// Revenue Contracts and their related Performance Obligations.

// Create The Contracts and Performance Obligations to be returned.
// Create a Revenue Contract.
ffrr__RevenueContract__c contract = new ffrr__RevenueContract__c();
contract.ffrr__Description__c = 'Description';
insert contract;

// Create Performance Obligations.
ffrr__PerformanceObligation__c po1 = new ffrr__PerformanceObligation__c();
po1.ffrr__RevenueContract__c = contract.id;
po1.ffrr__Description__c = 'PO 1';

ffrr__PerformanceObligation__c po2 = new ffrr__PerformanceObligation__c();
po2.ffrr__RevenueContract__c = contract.id;
po2.ffrr__Description__c = 'PO 2';

insert new List<ffrr__PerformanceObligation__c> {po1, po2};

// Call the Service passing the Contract Id as a list.
List<ffrr.RevenueContractService.RevenueContract> result = ffrr.RevenueContractService.retrieve(new List<Id>{contract.Id});

// Get the Revenue Contract.
ffrr.RevenueContractService.RevenueContract returnedContract = result[0];

// Get the Performance Obligations for this Revenue Contract. Size should be 2.
List<ffrr.RevenueContractService.PerformanceObligation> performanceObligations = returnedContract.PerformanceObligations;

retrieve

global static List<ffrr.RevenueContractService.RevenueContract> retrieve(List<Id> contractIds, ffrr.RevenueContractService.RetrieveOptions options)

Retrieves a list of RevenueContract records based on their IDs.

Input Parameters

Name Type Description
contractIds List<Id> A list of the IDs of RevenueContracts to retrieve.
options ffrr.RevenueContractService.RetrieveOptions A RetrieveOptions object which specifies additional retrieve options

Return Value

A list of RevenueContract objects with list of Performance Obligations populated.

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.

// In this example the Revenue Contract Service is used to retrieve existing
// Revenue Contracts without their related Performance Obligations.

// Create The Contracts and Performance Obligations to be returned.
// Create a Revenue Contract.
ffrr__RevenueContract__c contract = new ffrr__RevenueContract__c();
contract.ffrr__Description__c = 'Description';
insert contract;

// Create Performance Obligations.
ffrr__PerformanceObligation__c po1 = new ffrr__PerformanceObligation__c();
po1.ffrr__RevenueContract__c = contract.id;
po1.ffrr__Description__c = 'PO 1';

ffrr__PerformanceObligation__c po2 = new ffrr__PerformanceObligation__c();
po2.ffrr__RevenueContract__c = contract.id;
po2.ffrr__Description__c = 'PO 2';

insert new List<ffrr__PerformanceObligation__c> {po1, po2};

// Create a new instance of RetrieveOptions.
ffrr.RevenueContractService.RetrieveOptions options = new ffrr.RevenueContractService.RetrieveOptions();

// Do not query for Performance Obligations.
options.IncludePerformanceObligations = false;

// Call the Service passing the Contract Id as a list.
List<ffrr.RevenueContractService.RevenueContract> result = ffrr.RevenueContractService.retrieve(new List<Id>{contract.Id}, options);

// Get the Revenue Contract.
ffrr.RevenueContractService.RevenueContract returnedContract = result[0];

// Get the Performance Obligations for this Revenue Contract. Size should be 2.
List<ffrr.RevenueContractService.PerformanceObligation> performanceObligations = returnedContract.PerformanceObligations;

populate

global static ffrr.RevenueContractService.PopulateResult populate(List<Id> contractIds)

Populates the fields on the Performance Obligation Line Items related to the specified Revenue Contracts based on their Field Mapping Definition. Field values on a Performance Obligation will also be updated from the Controlling Performance Obligation Line Item.

Input Parameters

Name Type Description
contractIds List<Id> The IDs of the Revenue Contract records that are related to the Performance Obligation Line Items to be populated.

Return Value

A RevenueContractService.PopulateResult that contains the Ids of the updated Performance Obligation Line Items and the updated Performance obligations.

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.

// In this example the Revenue Contract Service is used to update existing
// Performance Obligation Line Item Records based on their Filed Mapping Definitions.

// Retrieve the Ids of the Revenue Contracts that will be updated.
List<ffrr__RevenueContract__c> contracts = [SELECT Id FROM ffrr__RevenueContract__c WHERE ffrr__AccountName__c = 'FF'];
List<Id> contractIds = new List<Id>();

for( ffrr__RevenueContract__c contract : contracts )
{
    contractIds.add(contract.Id);
}

// Get the result that contains the Ids of the Performance Obligation Line Items
// and Performance Obligations that have been updated successfully.
ffrr.RevenueContractService.PopulateResult result = ffrr.RevenueContractService.populate(contractIds);

populatePerformanceObligationLineItems

global static ffrr.RevenueContractService.PopulateResult populatePerformanceObligationLineItems(List<Id> performanceObligationLineItemIds)

Populates the fields of the specified Performance Obligation Line Items based on their Field Mapping Definition. If one of the specified Performance Obligation Line Items is the controlling one, then the parent Performance Obligation is updated too.

Input Parameters

Name Type Description
performanceObligationLineItemIds List<Id> The IDs of the Performance Obligation Line Items to be populated.

Return Value

A RevenueContractService.PopulateResult that contains the Ids of the updated Performance Obligation Line Items and any updated Performance obligations.

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.

// In this example the Revenue Contract Service is used to update existing
// Performance Obligation Line Item Records based on their Filed Mapping Definitions.

// Retrieve the Ids of the Performance Obligation Line Items that will be updated.
List<ffrr__PerformanceObligationLineItem__c> lineItems = [SELECT Id FROM ffrr__PerformanceObligationLineItem__c WHERE ffrr__AccountName__c = 'FF'];
List<Id> lineItemIds = new List<Id>();

for( ffrr__PerformanceObligationLineItem__c lineItem : lineItems )
{
    lineItemIds.add(lineItem.Id);
}

// Get the result that contains the Ids of the Performance Obligation Line Items
// and Performance Obligations that have been updated successfully.
ffrr.RevenueContractService.PopulateResult result = ffrr.RevenueContractService.populatePerformanceObligationLineItems(lineItemIds);

populateRelatedPerformanceObligationLineItems

global static ffrr.RevenueContractService.PopulateResult populateRelatedPerformanceObligationLineItems(List<Id> performanceObligationIds)

Populates the fields on the Performance Obligation Line Items related to the specified Performance Obligations based on their Field Mapping Definition. Field values on a Performance Obligation will also be updated from the Controlling Performance Obligation Line Item.

Input Parameters

Name Type Description
performanceObligationIds List<Id> The IDs of the Performance Obligation records that are related to the Performance Obligation Line Items to be populated.

Return Value

A RevenueContractService.PopulateResult that contains the Ids of the updated Performance Obligation Line Items and the updated Performance obligations.

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.

// In this example the Revenue Contract Service is used to update the related
// Performance Obligation Line Item Records, of the provided Performance Obligations, 
// based on their Filed Mapping Definitions.

// Retrieve the Ids of the Performance Obligations.
List<ffrr__PerformanceObligation__c> obligations = [SELECT Id FROM ffrr__PerformanceObligation__c WHERE ffrr__AccountName__c = 'FF'];
List<Id> obligationIds = new List<Id>();

for( ffrr__PerformanceObligation__c obligation : obligations )
{
    obligationIds.add(obligation.Id);
}

// Get the result that contains the Ids of the Performance Obligation Line Items
// and Performance Obligations that have been updated successfully.
ffrr.RevenueContractService.PopulateResult result = ffrr.RevenueContractService.populateRelatedPerformanceObligationLineItems(obligationIds);

populateFromControllingPoli

global static List<Id> populateFromControllingPoli(List<id> performanceObligationIds)

Populates the Performance Obligation with the values from the controlling Performance Obligation Line Item. If the controlling Performance Obligation Line Item is not set, the first one based on the Name order will be used.

Input Parameters

Name Type Description
performanceObligationIds List<id> The IDs of the Performance Obligations to be populated.

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.

// In this example the Revenue Contract Service is used to populate existing
// Performance Obligation records with the values from their controlling
// Performance Obligation Line Item.

// Get the Ids of all the Performance Obligations under a specific contract.
Id contractId = [Select Id from ffrr__RevenueContract__c WHERE ffrr__Description__c = 'FF Contract' LIMIT 1].Id;
List<ffrr__PerformanceObligation__c> performanceObligations = [Select Id from ffrr__PerformanceObligation__c WHERE ffrr__RevenueContract__c = :contractId ];

List<Id> performanceObligationIds = new List<Id>();
for( ffrr__PerformanceObligation__c performanceObligation : performanceObligations )
{
    performanceObligationIds.add( performanceObligation.Id );
}

// Populate the Performance Obligations based on their controlling 
// Performance Obligation Line Item.
List<Id> updatedPerformanceObligations = ffrr.RevenueContractService.populateFromControllingPoli( performanceObligationIds );

populateFromControllingPoliFromContract

global static List<Id> populateFromControllingPoliFromContract(List<Id> contractIds)

Populates the Performance Obligations for the specified Revenue Contracts with the values from the controlling Performance Obligation Line Items. If the controlling Performance Obligation Line Item is not set, the first one based on the Name order will be used.

Input Parameters

Name Type Description
contractIds List<Id> The IDs of the Performance Obligations to be populated.

retrievePerformanceObligations

global static Map<Id, List<ffrr.RevenueContractService.PerformanceObligation>> retrievePerformanceObligations(List<Id> contractIds)

Retrieves the Performance Obligation records related to the Revenue Contracts provided.

Input Parameters

Name Type Description
contractIds List<Id> The list of Revenue Contract IDs.

Return Value

Map of ffrr.RevenueContractService.PerformanceObligation by the ffrr__RevenueContract__c 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.

// Create a Revenue Contract.
ffrr__RevenueContract__c contract = new ffrr__RevenueContract__c();
contract.ffrr__Description__c = 'Description';
insert contract;

// Create Performance Obligations.
ffrr__PerformanceObligation__c po1 = new ffrr__PerformanceObligation__c();
po1.ffrr__RevenueContract__c = contract.id;
po1.ffrr__Description__c = 'PO 1';

ffrr__PerformanceObligation__c po2 = new ffrr__PerformanceObligation__c();
po2.ffrr__RevenueContract__c = contract.id;
po2.ffrr__Description__c = 'PO 2';

insert new List<ffrr__PerformanceObligation__c> {po1, po2};

// Call the Service.
Map<Id, List<ffrr.RevenueContractService.PerformanceObligation>> result = ffrr.RevenueContractService.retrievePerformanceObligations(new List<Id>{contract.Id});

savePerformanceObligations

global static ffrr.RevenueContractService.POSaveResult savePerformanceObligations(ffrr.RevenueContractService.POSaveContext saveContext)

Creates or updates Performance Obligations using the information provided.

Input Parameters

Name Type Description
saveContext ffrr.RevenueContractService.POSaveContext The save context containing the list of Performance Obligation records to be upserted, and records to be deleted.

Return Value

A POSaveResult containing the list of new and updated Performance Obligations and a POLISaveResult containing the list of new and updated Performance Obligations Line Items.

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.

// In this example the Revenue Contract Service is used to create and update Performance Obligations, and to create and update Performance Obligation Line Items.

/**
 * This section contains data setup.
 */

// Create the Revenue Contract.
ffrr__RevenueContract__c contract = new ffrr__RevenueContract__c();
insert contract;

// Create a Performance Obligation for the newly created Revenue Contract.
ffrr__PerformanceObligation__c performanceObligation = new ffrr__PerformanceObligation__c(
    ffrr__RevenueContract__c = contract.Id,
    ffrr__SSPOverride__c = 100
);
insert performanceObligation;

// Create a Performance Obligation Line Item for the newly created Performance Obligation.
ffrr__PerformanceObligationLineItem__c performanceObligationLineItem = new ffrr__PerformanceObligationLineItem__c(
    ffrr__PerformanceObligation__c = performanceObligation.Id,
    ffrr__AccountName__c = 'POLI Account Name'
);
insert performanceObligationLineItem;

// Set the new Line Item to be the Controlling POLI on the Performance Obligation.
performanceObligation.ffrr__ControllingPOLI__c = performanceObligationLineItem.Id;
update performanceObligation;

/**
 * End of data setup.
 */

/**
 * This section shows how to retrieve the records for manipulation, modify them, create new records, and save the changes.
 */

// Retrieve the Performance Obligations. These will also retrieve the Performance Obligation Line Items as a list property on the Performance Obligation.
List<Id> contractIds = new List<Id>{contract.Id};
Map<Id, List<ffrr.RevenueContractService.PerformanceObligation>> performanceObligationsByContractId = ffrr.RevenueContractService.retrievePerformanceObligations(contractIds);

// Update the SSP Override to 200.
List<ffrr.RevenueContractService.PerformanceObligation> performanceObligations = performanceObligationsByContractId.get(contract.Id);
ffrr.RevenueContractService.PerformanceObligation existingObligation = performanceObligations[0];
existingObligation.SSPOverride = 200;

// Create a new Performance Obligation Line Item and set the Account Name.
ffrr.RevenueContractService.PerformanceObligationLineItem newLineItemForExistingPO = new ffrr.RevenueContractService.PerformanceObligationLineItem();
newLineItemForExistingPO.AccountName = 'Example Account';

// Set the Controlling POLI on the new Line Item. This will cause the Controlling POLI to be updated to this Line Item.
// Setting 'IsControllingPOLI' on two or more Line Items belonging to the same Performance Obligation will result in an ffrr.Exceptions.AppException being thrown.
// Leaving 'IsControllingPOLI' set to NULL on all POLIs passed in will not change the Controlling POLI.
newLineItemForExistingPO.IsControllingPOLI = TRUE;
existingObligation.PerformanceObligationLineItems[0].IsControllingPOLI = FALSE;

// Add the new Line Item to the existing Performance Obligation.
existingObligation.PerformanceObligationLineItems.add(newLineItemForExistingPO);

// Create a new Performance Obligation.
ffrr.RevenueContractService.PerformanceObligation newObligation = new ffrr.RevenueContractService.PerformanceObligation();
newObligation.ContractId = contract.Id;
newObligation.SSPOverride = 300;

// Create a new Performance Obligation Line Item and set the Account Name.
ffrr.RevenueContractService.PerformanceObligationLineItem newLineItemForNewPO = new ffrr.RevenueContractService.PerformanceObligationLineItem();
newLineItemForNewPO.AccountName = 'New Example Account';

// Set the Controlling POLI on the new Line Item. This will cause the Controlling POLI to be updated to this Line Item.
// Setting 'IsControllingPOLI' on two or more Line Items belonging to the same Performance Obligation will result in an ffrr.Exceptions.AppException being thrown.
// Leaving 'IsControllingPOLI' set to NULL on all POLIs passed in will not change the Controlling POLI.
newLineItemForNewPO.IsControllingPOLI = TRUE;

// Create a new List of Line Items on the Performance Obligation containing the new Line Item.
newObligation.PerformanceObligationLineItems = new List<ffrr.RevenueContractService.PerformanceObligationLineItem>{newLineItemForNewPO};

// Add the new Performance Obligation to a list of Performance Obligations for saving.
List<ffrr.RevenueContractService.PerformanceObligation> newAndUpdatedPerformanceObligations = new List<ffrr.RevenueContractService.PerformanceObligation>{
    newObligation,
    existingObligation
};

ffrr.RevenueContractService.POSaveContext saveContext = new ffrr.RevenueContractService.POSaveContext();
saveContext.PerformanceObligations = newAndUpdatedPerformanceObligations;

// Save the new and updated Performance Obligations.
ffrr.RevenueContractService.POSaveResult result = ffrr.RevenueContractService.savePerformanceObligations(saveContext);

// Query the new Performance Obligations for use later on.
List<ffrr__PerformanceObligation__c> newPerformanceObligations = [SELECT Id, ffrr__SSPOverride__c FROM ffrr__PerformanceObligation__c WHERE ID IN :result.NewRecordIds];

// Query the updated Performance Obligations for use later on.
List<ffrr__PerformanceObligation__c> updatedPerformanceObligations = [SELECT Id, ffrr__SSPOverride__c FROM ffrr__PerformanceObligation__c WHERE ID IN :result.UpdatedRecordIds];

// Query all the new and updated Performance Obligations for use later on.
List<ffrr__PerformanceObligation__c> allPerformanceObligations = [SELECT Id, ffrr__SSPOverride__c FROM ffrr__PerformanceObligation__c WHERE ID IN :result.AllRecordIds];

searchTemplates

global static List<ffrr.ViewService.Reference> searchTemplates(String searchTerm)

Searches for ffrr__Template__c records by name, whose related setting has an ffrr__object__c of ffrr__PerformanceObligation__c and ffrr__UseInRevenueContract__c is false. Returns 100 results by default.

Input Parameters

Name Type Description
searchTerm String The text to search for.

Return Value

A List of ViewService.Reference containing the Id and the name of matching results.

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.

// In this example the Revenue Service is used to search for templates, whose related Setting has an 
// ffrr__object__c of ffrr__PerformanceObligation__c and ffrr__UseInRevenueContract__c is false.

// Specify the term that matches the names of the templates.
// This will return any template that contains "Percent Complete"
String searchTerm = 'Percent Complete';

// Get the references of the templates matching the search term from the result.
List<ffrr.ViewService.Reference> result = ffrr.RevenueContractService.searchTemplates( searchTerm );

searchTemplates

global static List<ffrr.ViewService.Reference> searchTemplates(String searchTerm, ffrr.RevenueContractService.RecordSearchOptions options)

Searches for ffrr__Template__c records by name, whose related setting has an ffrr__object__c of ffrr__PerformanceObligation__c and ffrr__UseInRevenueContract__c is false.

Input Parameters

Name Type Description
searchTerm String The text to search for.
options ffrr.RevenueContractService.RecordSearchOptions Enables you to set options related to searching for templates.

Return Value

A List of ViewService.Reference containing the Id and the name of matching results.

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.

// In this example the Revenue Service is used to search for templates, whose related Setting has an 
// ffrr__object__c of ffrr__PerformanceObligation__c and ffrr__UseInRevenueContract__c is false.
// Additionally, a limit is used to reduce the number of results.

// Specify the term that matches the names of the templates.
// This will return any template that contains "Deliverable"
String searchTerm = 'Deliverable';

// Specify the maximum number of rows to be returned from the search operation.
ffrr.RevenueContractService.RecordSearchOptions options = new ffrr.RevenueContractService.RecordSearchOptions();
options.NumberOfRows = 10;

// Get the references of the first 10 templates matching the search term from the result.
List<ffrr.ViewService.Reference> result = ffrr.RevenueContractService.searchTemplates( searchTerm );

searchRecords

global static Map<Schema.SObjectType, List<ffrr.ViewService.Reference>> searchRecords(String searchTerm)

Searches for Records that are related to ffrr_Settings__c, where ffrr__UseInRevenueContract__c is TRUE, that start with the search term in their Name Field. Maximum of 100 records for each SObject Type will be returned by default. Wildcards are supported.

Input Parameters

Name Type Description
searchTerm String The text to search for.

Return Value

A List of the records found keyed by their SObject Type.

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.

// In this example the Revenue Contract Service is used to search for source records that are related
// to ffrr_Settings__c, where ffrr__UseInRevenueContract__c is TRUE.

// Specify the term that matches the names of the source records.
// This will return any source record that starts with "Project" or "project".
String searchTerm = 'Project';

// Get the references of the source records, keyed by their type, matching the search term from the result.
Map<Schema.SObjectType, List<ffrr.ViewService.Reference>> result = ffrr.RevenueContractService.searchRecords( searchTerm );

searchRecords

global static Map<Schema.SObjectType, List<ffrr.ViewService.Reference>> searchRecords(String searchTerm, ffrr.RevenueContractService.RecordSearchOptions options)

Searches for Records that are related to ffrr_Settings__c, where ffrr__UseInRevenueContract__c is TRUE, that start with the search term in their Name Field. Wildcards are supported.

Input Parameters

Name Type Description
searchTerm String The text to search for.
options ffrr.RevenueContractService.RecordSearchOptions Enables you to set options related to searching.

Return Value

A List of the records found keyed by their SObject Type.

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.

// In this example the Revenue Contract Service is used to search for source records that are related
// to ffrr_Settings__c, where ffrr__UseInRevenueContract__c is TRUE.
// Additionally, a limit is used to reduce the number of results.

// Specify the term that matches the names of the source records.
// This will return any source record that starts with "Project" or "project".
String searchTerm = 'Project';

// Specify the maximum number of rows to be returned from the search operation.
ffrr.RevenueContractService.RecordSearchOptions options = new ffrr.RevenueContractService.RecordSearchOptions();
options.NumberOfRows = 10;

// Get the references of the first 10 source records, keyed by their type, matching the search term from the result.
Map<Schema.SObjectType, List<ffrr.ViewService.Reference>> result = ffrr.RevenueContractService.searchRecords( searchTerm );

searchRecords

global static Set<ffrr.RevenueContractService.SourceReference> searchRecords(String searchTerm, String objectName, List<String> filterPath, String currCode, ffrr.RevenueContractService.RecordSearchOptions options)

Searches for Records that are related to ffrr_Settings__c, where ffrr__UseInRevenueContract__c is TRUE and which are not associated with an existing Performance Obligation.

Input Parameters

Name Type Description
searchTerm String The text to search for (wildcards of '*' and '?' are supported).
objectName String The API name of the type of source object to search for (or '*' for all types).
filterPath List<String> The path (via lookups) to the field to search against (with the 'searchTerm') - this only applies with an 'objectname' to specify the starting point (otherwise the objects name field will be used).
currCode String The currency of the records we are searching for.
options ffrr.RevenueContractService.RecordSearchOptions Enables you to set options related to searching (e.g. 'NumberOfRows' to limit the number of rows returned).

Return Value

Information about the records found.

getSourceObjectInfo

global static Map<String, String> getSourceObjectInfo()

Searches for all the settings where ffrr__UseInRevenueContract__c is TRUE and which have a template.

Return Value

A map keyed by all the source objects in the selected settings with the object label as the map value.

ffrr.RevenueContractService.RevenueContract

global class RevenueContract

Represents a Revenue Contract record

Properties

Name Type Description
Id Id The ID of the Revenue Contract
Name String The name of the Revenue Contract
CurrencyIsoCode String The currency code of the Revenue Contract
Description String The description of the Revenue Contract
AccountName String The account name of the Revenue Contract
Active Boolean Specifies whether the Revenue Contract is active
AllocationRatio Decimal The ratio used to allocate revenue to linked Performance Obligations
AllocationStatus String Shows if the Revenue for this contract has been fully allocated, or needs reallocating
EndDate Date The end date of this Revenue Contract
StartDate Date The start date of the Revenue Contract
PerformanceObligations List<ffrr.RevenueContractService.PerformanceObligation> All Performance Obligations related to this contract
PerformanceObligationsCount Decimal The number of Performance Obligations on this Contract
Revenue Decimal The value that will be allocated to the Performance Obligations. Uses Total Revenue, or Revenue Override if populated
RevenueAllocated Boolean Indicates if the Revenue for this contract has been allocated successfully
RevenueRecognitionComplete Boolean Indicates whether this Revenue Contract is complete
TotalAllocatedRevenue Decimal Total Allocated Revenue for this Revenue Contract
TotalAllocatedRevenueOverride Decimal Sum of Allocated Revenue Override values from all linked Performance Obligations
TotalRecognizedToDate Decimal Total Recognized To Date for this Revenue Contract
TotalSSP Decimal Sum of Standalone Selling Prices from all linked Performance Obligations

Methods

RevenueContract

global RevenueContract()

ffrr.RevenueContractService.PerformanceObligation

global class PerformanceObligation

Represents a Performance Obligation record

Properties

Name Type Description
Id Id The ID of the Performance Obligation
Name String The name of the Performance Obligation
ContractId Id The Revenue Contract of the Performance Obligation
CurrencyIsoCode String The currency code of the Performance Obligation
Description String The description of the Performance Obligation
AccountName String The account name of the Performance Obligation
Active Boolean Specifies whether the Performance Obligation is active
Complete Boolean Specifies whether the Performance Obligation is complete
PercentComplete Decimal The percentage the Performance Obligation is complete
StartDate Date The start date of the Performance Obligation
EndDate Date The end date of the Performance Obligation
SSP Decimal The SSP of the Performance Obligation
TotalSSP Decimal Sum of the SSPs for all Performance Obligation Line Items in the Performance Obligation.
SSPOverride Decimal The SSP override for the Performance Obligation
Template ffrr.ViewService.Reference The template of the Performance Obligation
Revenue Decimal The revenue of the Performance Obligation
AllocatedRevenue Decimal The allocated revenue of the Performance Obligation
AllocatedRevenueOverride Decimal The allocated revenue override of the Performance Obligation
RecognizedToDate Decimal The recognized to date of the Performance Obligation
RevRecComplete Boolean Specifies whether the Performance Obligation is revenue recognition complete
ReadyForRevRec Boolean Specifies whether the Performance Obligation is ready for revenue recognition
BalanceSheet String The balance sheet name for the Performance Obligation
IncomeStatement String The income statement name for the Performance Obligation
CostCenter String The cost center name for the Performance Obligation
PerformanceObligationLineItems List<ffrr.RevenueContractService.PerformanceObligationLineItem>

Methods

PerformanceObligation

global PerformanceObligation()

ffrr.RevenueContractService.PerformanceObligationLineItem

global class PerformanceObligationLineItem

Represents a Performance Obligation Line Item record.

Properties

Name Type Description
Id Id The ID of the Performance Obligation Line Item.
Name String The name of the Performance Obligation Line Item.
AccountName String The Account name of the Performance Obligation Line Item.
Active Boolean Indicates whether the Performance Obligation Line Item is active.
BalanceSheetAccount String The Balance Sheet Account of the Performance Obligation Line Item.
Completed Boolean Indicates whether the Performance Obligation Line Item is complete.
CostCenterAccount String The Cost Center Account of the Performance Obligation Line Item.
Description String The Description of the Performance Obligation Line Item.
EndDate Date The End Date of the Performance Obligation Line Item.
FieldMapping ffrr.ViewService.Reference The Field Mapping Definition of the Performance Obligation Line Item. This determines which fields get populated from Source Records when "Update from Source" occurs.
IncomeStatementAccount String The Income Statement Account of the Performance Obligation Line Item.
IsControllingPOLI Boolean Indicates whether the Performance Obligation Line Item is the Controlling Performance Obligation Line Item. The Performance Obligation will take values from the Controlling Performance Obligation Line Item when "Update from Source" occurs.
PercentageComplete Decimal The Percentage that this Performance Obligation Line Item is complete, using the scale of 100 to denote 100%.
PerformanceObligationId Id The ID of the Performance Obligation this Performance Obligation Line Item belongs to.
Revenue Decimal The Revenue for the Performance Obligation Line Item.
SSP Decimal The SSP of the Performance Obligation Line Item.
SourceRecordSetting ffrr.ViewService.Reference The Setting used by the Source Record related to this Performance Obligation Line Item.
SourceRecord ffrr.ViewService.Reference The Source Record linked to this Performance Obligation Line Item.
StartDate Date The Start Date of the Performance Obligation Line Item.
CurrencyIsoCode String The Currency of the Performance Obligation Line Item.

Methods

PerformanceObligationLineItem

global PerformanceObligationLineItem()

ffrr.RevenueContractService.RetrieveOptions

global class RetrieveOptions

Contains additional options related to retrieving RevenueContract instances

Properties

Name Type Description
IncludePerformanceObligations Boolean Specifies whether to retrieve PerformanceObligation instances along with their parent Revenue Contract. Defaults to true.

Methods

RetrieveOptions

global RetrieveOptions()

ffrr.RevenueContractService.PopulateResult

global class PopulateResult

Contains information resulting from the populate operation.

Properties

Name Type Description
UpdatedPolis List<Id> The ids of the updated Performance Obligation Line Items.
UpdatedPos List<Id> The ids of the updated Performance Obligations.

ffrr.RevenueContractService.SaveResult

global abstract class SaveResult

Contains the results of the Save operation

Properties

Name Type Description
UpdatedRecordIds List<Id> The IDs of updated records.
NewRecordIds List<Id> The IDs of created records.
AllRecordIds List<Id> The IDs of both the created and updated records.

ffrr.RevenueContractService.POSaveResult

global class POSaveResult extends SaveResult

Contains the results of the Performance Obligation Save operation

This class extends ffrr.RevenueContractService.SaveResult

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 list should be populated with RevenueContractService.PerformanceObligations,
// and each of those should contain a list of RevenueContractService.PerformanceObligationLineItems.
List<ffrr.RevenueContractService.PerformanceObligation> newAndUpdatedPerformanceObligations = new List<ffrr.RevenueContractService.PerformanceObligation>();

ffrr.RevenueContractService.POSaveContext saveContext = new ffrr.RevenueContractService.POSaveContext();
saveContext.PerformanceObligations = newAndUpdatedPerformanceObligations;

// Save the new and updated Performance Obligations.
ffrr.RevenueContractService.POSaveResult result = ffrr.RevenueContractService.savePerformanceObligations(saveContext);

// Query the new Performance Obligations.
List<ffrr__PerformanceObligation__c> newPerformanceObligations = [SELECT Id, ffrr__SSPOverride__c FROM ffrr__PerformanceObligation__c WHERE ID IN :result.NewRecordIds];

// Query the updated Performance Obligations.
List<ffrr__PerformanceObligation__c> updatedPerformanceObligations = [SELECT Id, ffrr__SSPOverride__c FROM ffrr__PerformanceObligation__c WHERE ID IN :result.UpdatedRecordIds];

// Query all the new and updated Performance Obligations.
List<ffrr__PerformanceObligation__c> allPerformanceObligations = [SELECT Id, ffrr__SSPOverride__c FROM ffrr__PerformanceObligation__c WHERE ID IN :result.AllRecordIds];

// Get the Line Item results.
ffrr.RevenueContractService.POLISaveResult lineItemResult = result.POLISaveResult;

// Query the new Performance Obligation Line Items.
List<ffrr__PerformanceObligationLineItem__c> newPerformanceObligationLineItems = [SELECT Id, ffrr__AccountName__c FROM ffrr__PerformanceObligationLineItem__c WHERE ID IN :lineItemResult.NewRecordIds];

// Query the updated Performance Obligation Line Items.
List<ffrr__PerformanceObligationLineItem__c> updatedPerformanceObligationLineItems = [SELECT Id, ffrr__AccountName__c FROM ffrr__PerformanceObligationLineItem__c WHERE ID IN :lineItemResult.UpdatedRecordIds];

// Query all the new and updated Performance Obligation Line Items.
List<ffrr__PerformanceObligationLineItem__c> allPerformanceObligationLineItems = [SELECT Id, ffrr__AccountName__c FROM ffrr__PerformanceObligationLineItem__c WHERE ID IN :lineItemResult.AllRecordIds];

Properties

Name Type Description
POLISaveResult ffrr.RevenueContractService.POLISaveResult

ffrr.RevenueContractService.POLISaveResult

global class POLISaveResult extends SaveResult

This class extends ffrr.RevenueContractService.SaveResult

ffrr.RevenueContractService.POSaveContext

global class POSaveContext extends DeleteContext

Specifies information needed to save Performance Obligations

This class extends ffrr.RevenueContractService.DeleteContext

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 example creates a new POSaveContext ready to be passed to the ffrr.RevenueContractService.savePerformanceObligations() method.

// Create a new POSaveContext.
ffrr.RevenueContractService.POSaveContext saveContext = new ffrr.RevenueContractService.POSaveContext();

// Pass in your list of Performance Obligations to update.
saveContext.PerformanceObligations = new List<ffrr.RevenueContractService.PerformanceObligation>();

/*
 * Pass in record IDs to delete.
 * The order in which records are deleted is as follows:
 * 1: ffrr__PerformanceObligationLineItem__c
 * 2: ffrr__PerformanceObligation__c
 * 3: ffrr__RevenueContract__c
 *
 * Deleting a Revenue Contract will delete all related Performance Obligations and Line Items,
 * and deleting a Performance Obligation will delete all related Line Items.
 */
// Pass in any Contract IDs you want to delete.
saveContext.ContractsToDelete = new List<Id>();

// Pass in any Performance Obligation IDs you want to delete.
saveContext.PerformanceObligationsToDelete = new List<Id>();

// Pass in any Performance Obligation Line Item IDs you want to delete.
saveContext.POLIsToDelete = new List<Id>();

Properties

Name Type Description
PerformanceObligations List<ffrr.RevenueContractService.PerformanceObligation> The list of Performance Obligation records to be upserted.

Methods

POSaveContext

global POSaveContext()

ffrr.RevenueContractService.DeleteContext

global abstract class DeleteContext

Base class that details Revenue Contracts and related records to be deleted

Properties

Name Type Description
ContractsToDelete List<Id> The Ids of the Revenue Contract records to be deleted
PerformanceObligationsToDelete List<Id> The Ids of the Performance Obligation records to be deleted
POLIsToDelete List<Id> The Ids of the Performance Obligation Line Item records to be deleted

Methods

DeleteContext

global DeleteContext()

ffrr.RevenueContractService.RecordSearchOptions

global class RecordSearchOptions

Enables you to set options related to searching for records.

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.

// Use the Record Search Options to specify the maximum number of results
// to be returned from the Search Templates operation.
ffrr.RevenueContractService.RecordSearchOptions options = new ffrr.RevenueContractService.RecordSearchOptions();
options.NumberOfRows = 10;

Properties

Name Type Description
NumberOfRows Integer The maximum number of results to be returned

Methods

RecordSearchOptions

global RecordSearchOptions()

ffrr.RevenueContractService.PopulateContext

global class PopulateContext

Object that wraps the IDs that are needed for the populateFromSourceRecords methods.

Properties

Name Type Description
SourceRecordIDs List<ID> The Ids of the Source Records that are to be used to find Performance Obligation Line Items that need updating from those source records.

Methods

PopulateContext

global PopulateContext()

ffrr.RevenueContractService.SourceReference

global class SourceReference

Contains information about the records found from the Search process.

Properties

Name Type Description
Id String The Id of the source record this class contains information about.
AccountName String The account name of the source record.
Description String The description of the source record.
SelectPath List<ffrr.RevenueContractService.PathItem> The search path used to find this record.
SettingsPath List<ffrr.RevenueContractService.PathItem> The hierarchy of parent records leading to this source record.

ffrr.RevenueContractService.PathItem

global class PathItem

Contains information about a step in the metadata chain.

Properties

Name Type Description
RecordName String The type of the SObject at this point in the path.
ItemLabel String The label of the SObject at this point in the path.
© Copyright 2009–2017 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.