ffrr.RevenueContractServiceglobal with sharing class RevenueContractService
Methods
createglobal static List<ffrr.RevenueContractService.ManageRevenueContractResult> create(List<ffrr.RevenueContractService.ManageRevenueContractContext> contexts) Creates or updates revenue contracts with the source records provided.
Depending on the contexts that you provide, the process runs synchronously or asynchronously. See the description below. If the process runs asynchronously, you might receive an email notification once it finishes. This is determined by the value of ffrr__BatchSetting__c.ffrr__ManageRevenueContractSendEmail__c custom setting field. Input Parameters
Return ValueList of ManagementRevenueContractResult with a single instance. 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 synchronously create a new revenue contract. // Performance obligations corresponding to the provided source records are created in the new revenue contract. // Fields on the performance obligation lines related to revenue contract are populated. // Revenue is allocated for all the performance obligations in the contract. // Finally, revenue schedules are generated for the performance obligations. ffrr.RevenueContractService.ManageRevenueContractContext context = new ffrr.RevenueContractService.ManageRevenueContractContext(); // Set the IDs of the source records that will be used to create performance obligations. // The source records must not be linked to performance obligation lines in another revenue contract. // The number of source records determines whether the process runs synchronously or asynchronously. // In this example, we assume that you have provided five source records and that you haven't changed the default limit. context.SourceRecordIds = selectedSourceRecords; // You can optionally specify additional fields for the new revenue contract. context.Contract = new ffrr.RevenueContractService.RevenueContract(); context.Contract.StartDate = Date.today(); context.Contract.EndDate = Date.today().addMonths(6); // Add the context to a list of contexts. List<ffrr.RevenueContractService.ManageRevenueContractContext> contexts = new List<ffrr.RevenueContractService.ManageRevenueContractContext>{context}; // Call the create method with the list of contexts. List<ffrr.RevenueContractService.ManageRevenueContractResult> results = ffrr.RevenueContractService.create(contexts); // The list of results contains a single instance of ManageRevenueContractResult. // In this example, the Contract property from the result is populated with a representation of the new revenue contract. // The Status property of the result contains the Allocation Status of the revenue contract. // If an error occurs during the process, the Status property is set to "Error". In that case, use the Errors property to view the error. // If an error occurs while generating revenue schedules, the error messages is also added to the Errors property. // However, the Status properly still contains the Allocation Status of the revenue contract. 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 synchronously update an existing revenue contract // using the specified source records to create performance obligations and performance obligation lines. // Fields on the new performance obligation lines related to revenue contract are populated. // Revenue is automatically reallocated for all the performance obligations in the revenue contract. // Finally, revenue schedules are generated for the performance obligations. This includes both existing and new performance obligations. ffrr.RevenueContractService.ManageRevenueContractContext context = new ffrr.RevenueContractService.ManageRevenueContractContext(); // Set the IDs of the source records that will be used to create performance obligations. // The source records must not be linked to performance obligation lines in another revenue contract. // Source records with performance obligations that are already linked to the specified revenue contract are ignored. // The number of source records determines whether the process runs synchronously or asynchronously. // In this example, we assume that you have provided five source records and that you haven't changed the default limit. context.SourceRecordIds = selectedSourceRecords; // Specify the ID of the revenue contract that will be updated with new performance obligations. // We assume that you have already retrieved the ID of the revenue contract. context.Contract = new RevenueContractService.RevenueContract(); context.Contract.Id = existingRevenueContractId; // Add the context to a list of contexts. List<ffrr.RevenueContractService.ManageRevenueContractContext> contexts = new List<ffrr.RevenueContractService.ManageRevenueContractContext>{context}; // Call the create method with the list of contexts. List<ffrr.RevenueContractService.ManageRevenueContractResult> results = ffrr.RevenueContractService.create(contexts); // The list of results contains a single instance of ManageRevenueContractResult. // In this example, the Contract property from the result contains the newly created performance obligations. // Existing performance obligations are excluded from the result. // The Status property of the result contains the Allocation Status of the revenue contract. // If an error occurs during the process, the Status property is set to "Error". // In that case, use the Errors property to view the error. // If an error occurs while generating revenue schedules, the error messages is also added to the Errors property. // However, the Status properly still contains the Allocation Status of the revenue contract. 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 two new revenue contracts asynchronously. // After the performance obligations are created for each contract, fields on the performance obligation lines are populated // and revenue is allocated for the all the performance obligations. // Finally, revenue schedules are generated for the performance obligations of both contracts. ffrr.RevenueContractService.ManageRevenueContractContext contextUSD = new ffrr.RevenueContractService.ManageRevenueContractContext(); contextUSD.SourceRecordIds = usdSourceRecordIds; ffrr.RevenueContractService.ManageRevenueContractContext contextEUR = new ffrr.RevenueContractService.ManageRevenueContractContext(); contextEUR.SourceRecordIds = eurSourceRecordIds; // Add the two contexts to a list of contexts. List<ffrr.RevenueContractService.ManageRevenueContractContext> contexts = new List<ffrr.RevenueContractService.ManageRevenueContractContext>{contextUSD, contextEUR}; // Call the create method with the list of contexts. // When the list contains multiple contexts, the process always runs asynchronously, regardless of the number of source records. List<ffrr.RevenueContractService.ManageRevenueContractResult> results = ffrr.RevenueContractService.create(contexts); // The list of results contains a single instance of ManageRevenueContractResult. // Only the ProcessRunId property is populated. The remaining properties are set to null. // You can retrieve the process run record to view additional information. fferpcore__ProcessRun__c processRun = [SELECT Id FROM fferpcore__ProcessRun__c WHERE Id = :results[0].ProcessRunId LIMIT 1]; // The process run record contains the number of records pending to be processed, // the number of successfully processed records, the number of errors, and the start and finish time. // If the value of the ffrr__BatchSetting__c.ffrr__ManageRevenueContractSendEmail__c custom setting field is set to true, // you will receive an email notification once the process finishes. This is set to true by default. // The email contains a summary of the process run and a direct link to the process run record. // If the value of the ffrr__RevenueRecognitionSettings__c.ffrr__DisableSchedulesCreationFromContracts__c custom setting field is set to true (default is false), // the Revenue Schedule creation process will be skipped as part of the Revenue Contract creation. populateglobal 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
Return ValueA 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); populateFromControllingPoliglobal 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
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 ); populateFromControllingPoliFromContractglobal 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
populateFromSourceRecordsglobal 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. Input Parameters
Return ValueA 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 ); } populateFromSourceRecordsAsyncglobal 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
Return ValueThe 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 ); } populatePerformanceObligationLineItemsglobal 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
Return ValueA 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); populateRelatedPerformanceObligationLineItemsglobal 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
Return ValueA 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); reallocateglobal static void reallocate(List<Id> contractIds) Calculates the Allocated Revenue for the Performance Obligation records related to the Revenue Contracts provided. Input Parameters
reallocatePerformanceObligationsglobal static void reallocatePerformanceObligations(List<Id> performanceObligationIds) Calculates the Allocated Revenue for the supplied Performance Obligation records. Input Parameters
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. // Get a subset of all the Performance Obligations to Allocate from a Revenue Contract // e.g In a Batch execute method. List<ffrr__PerformanceObligation__c> obligations = [SELECT Id FROM ffrr__PerformanceObligation__c WHERE ffrr__RevenueContract__c = :contractId LIMIT 200]; List<Id> obligationIds = new List<Id>(); for( ffrr__PerformanceObligation__c obligation : obligations ) { obligationIds.add(obligation.Id); } ffrr.RevenueContractService.reallocatePerformanceObligations(obligationIds); retrieveglobal static List<ffrr.RevenueContractService.RevenueContract> retrieve(List<Id> contractIds) Retrieves a list of RevenueContract records based on their IDs. Input Parameters
Return ValueA 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; retrieveglobal 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
Return ValueA 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; retrievePerformanceObligationsglobal static Map<Id, List<ffrr.RevenueContractService.PerformanceObligation>> retrievePerformanceObligations(List<Id> contractIds) Retrieves the Performance Obligation records related to the Revenue Contracts provided. Input Parameters
Return ValueMap 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}); savePerformanceObligationsglobal static ffrr.RevenueContractService.POSaveResult savePerformanceObligations(ffrr.RevenueContractService.POSaveContext saveContext) Creates or updates Performance Obligations using the information provided. Input Parameters
Return ValueA 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]; searchRecordsglobal 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
Return ValueA 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 ); searchRecordsglobal 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
Return ValueA 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 ); searchRecordsglobal 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
Return ValueInformation about the records found. searchTemplatesglobal 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
Return ValueA 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 ); searchTemplatesglobal 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
Return ValueA 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 ); getSourceObjectInfoglobal static Map<String, String> getSourceObjectInfo() Searches for all the settings where ffrr__UseInRevenueContract__c is TRUE and which have a template. Return ValueA map keyed by all the source objects in the selected settings with the object label as the map value. transferPreviouslyRecognizedglobal static List<ffrr.RevenueContractService.TransferResult> transferPreviouslyRecognized(ffrr.RevenueContractService.TransferContext context) Creates In Progress Revenue Recognition Transactions with Transaction Lines for Performance Obligation Line records provided that are related to source records with committed Transactions. Transaction Lines are only created for active Performance Obligations with valid templates. Input Parameters
Return ValueThe List of the created Revenue Recognition Transaction IDs. 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 Revenue Recognition Transactions // for specific Performance Obligation records that are related to source records with committed Transactions. // Select the Performance Obligation Line Items related to the source records. Any "Committed" Revenue, no later than the cutoff date, // will be taken into account from this proccess. // The following selects the Performance Obligation Line Items whose related contract's start date is after the 2017-01-01. Date startOf2017 = Date.newInstance(2017, 01, 01); List<ffrr__PerformanceObligationLineItem__c> lineItems = [SELECT Id FROM ffrr__PerformanceObligationLineItem__c WHERE ffrr__PerformanceObligation__r.ffrr__RevenueContract__r.ffrr__StartDate__c >= :startOf2017]; List<Id> lineItemIds = new List<Id>(); for( ffrr__PerformanceObligationLineItem__c lineItem : lineItems ) { lineItemIds.add(lineItem.Id); } // Create the Transfer Context. ffrr.RevenueContractService.TransferContext context = new ffrr.RevenueContractService.TransferContext(); context.RecognitionDate = Date.newInstance(2017, 1, 1); context.CutoffDate = Date.newInstance(2016, 12, 31); context.Description = 'Previously recognized before 2017'; context.LegislationType = 'ASC 605'; context.Period = [SELECT Id FROM ffrr__RecognitionPeriod__c WHERE Name = '2017/001' LIMIT 1].Id; // Set the Performance Obligation Line Item Ids to the context. context.PerformanceObligationLineItems = lineItemIds; // Retrieve the result containing the created Transactions. List<ffrr.RevenueContractService.TransferResult> result = ffrr.RevenueContractService.transferPreviouslyRecognized(context); transferPreviouslyRecognizedAsyncglobal static Id transferPreviouslyRecognizedAsync(ffrr.RevenueContractService.TransferContext context) Creates In Progress Revenue Recognition Transactions with Transaction Lines for all Performance Obligation records that are related to source records with committed Transactions. Transaction Lines are only created for active Performance Obligations with valid templates. Input Parameters
Return ValueThe ID of the AsyncApexJob. 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 Revenue Recognition Transactions asynchronously // for all the Performance Obligation records that are related to source records with committed Transactions. ffrr.RevenueContractService.TransferContext context = new ffrr.RevenueContractService.TransferContext(); context.RecognitionDate = Date.newInstance(2016, 1, 1); context.CutoffDate = Date.newInstance(2015, 12, 31); context.Description = 'Previously recognized before 2016'; context.LegislationType = 'ASC 605'; context.Period = [SELECT Id FROM ffrr__RecognitionPeriod__c WHERE Name = '2017/001' LIMIT 1].Id; // Retrieve the Id of the Batch Job that's been started. Id resultingBatchId = ffrr.RevenueContractService.transferPreviouslyRecognizedAsync(context); ffrr.RevenueContractService.DeleteContextglobal abstract with sharing class DeleteContext Base class that details Revenue Contracts and related records to be deleted Properties
MethodsDeleteContextglobal DeleteContext() ffrr.RevenueContractService.Filterglobal with sharing class Filter The filter class used to specify field/value pairs when filtering on Revenue Contracts during the transfer previously recognized process. 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 new text field Filter ffrr.RevenueContractService.Filter textFilter = new ffrr.RevenueContractService.Filter(); // Set the field to filter on to be the Description__c field. This could be any text or lookup field. textFilter.Field = ffrr__RevenueContract__c.ffrr__Description__c; // Set the value to filter on. textFilter.Value = 'Ready for Transfer'; // You can also create filters for Lookups and Booleans ffrr.RevenueContractService.Filter booleanFilter = new ffrr.RevenueContractService.Filter(); // Set the field to filter on to be the Description__c field. This could be any text or lookup field. booleanFilter.Field = ffrr__RevenueContract__c.ffrr__Active__c; // Set the value to filter on. booleanFilter.Value = 'true'; ffrr.RevenueContractService.Filter lookupFilter = new ffrr.RevenueContractService.Filter(); // Set the field to filter on to be the Description__c field. This could be any text or lookup field. lookupFilter.Field = ffrr__RevenueContract__c.ffrr__Account__c; // Set the value to filter on. lookupFilter.Value = [SELECT Id FROM Account LIMIT 1].Id; Properties
MethodsFilterglobal Filter() ffrr.RevenueContractService.PathItemglobal with sharing class PathItem Contains information about a step in the metadata chain. Properties
ffrr.RevenueContractService.PerformanceObligationglobal with sharing class PerformanceObligation Represents a Performance Obligation record Properties
MethodsPerformanceObligationglobal PerformanceObligation() ffrr.RevenueContractService.PerformanceObligationLineItemglobal with sharing class PerformanceObligationLineItem Represents a Performance Obligation Line Item record. Properties
MethodsPerformanceObligationLineItemglobal PerformanceObligationLineItem() ffrr.RevenueContractService.PopulateContextglobal with sharing class PopulateContext Object that wraps the IDs that are needed for the populateFromSourceRecords methods. Properties
MethodsPopulateContextglobal PopulateContext() ffrr.RevenueContractService.PopulateResultglobal with sharing class PopulateResult Contains information resulting from the populate operation. Properties
ffrr.RevenueContractService.POLISaveResultglobal with sharing class POLISaveResult extends SaveResult This class extends ffrr.RevenueContractService.SaveResult ffrr.RevenueContractService.POSaveContextglobal with sharing 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
MethodsPOSaveContextglobal POSaveContext() ffrr.RevenueContractService.POSaveResultglobal with sharing 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
ffrr.RevenueContractService.RecordSearchOptionsglobal with sharing 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
MethodsRecordSearchOptionsglobal RecordSearchOptions() ffrr.RevenueContractService.RetrieveOptionsglobal with sharing class RetrieveOptions Contains additional options related to retrieving RevenueContract instances Properties
MethodsRetrieveOptionsglobal RetrieveOptions() ffrr.RevenueContractService.RevenueContractglobal with sharing class RevenueContract Represents a Revenue Contract record Properties
MethodsRevenueContractglobal RevenueContract() ffrr.RevenueContractService.ManageRevenueContractContextglobal with sharing class ManageRevenueContractContext Context used when creating or updating a revenue contract. Contains information about the revenue contact and the related source 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. // Create an instance of ManageRevenueContractContext to provide the source records when // creating or updating a revenue contract. // Create a new instance of ManageRevenueContractContext ffrr.RevenueContractService.ManageRevenueContractContext context = new ffrr.RevenueContractService.ManageRevenueContractContext(); // Retrieve the IDs of source records used to create performance obligations // The list can contain IDs from different objects // We recommend using one of the searchRecords methods to retrieve only source records that are not already linked to a performance obligation. // In this example, we retrieve all PSA projects related to the engagement with the name of ENG0000000. ffrr.RevenueContractService.RecordSearchOptions options = new ffrr.RevenueContractService.RecordSearchOptions(); options.NumberOfRows = 5; List<String> lookupPath = new List<String> { 'pse__Engagement__c','Name' }; Set<ffrr.RevenueContractService.SourceReference> sourceRecordsReference = ffrr.RevenueContractService.searchRecords('ENG0000000','pse__Proj__c', lookupPath, 'USD', options); List<Id> sourceRecordsIds = new List<Id>(); for(ffrr.RevenueContractService.SourceReference source : sourceRecords) { sourceRecordsIds.add(source.Id); } context.SourceRecordIds = sourceRecordsIds; // Use the Contract property to specify which revenue contract is being updated. context.Contract = new ffrr.RevenueContractService.RevenueContract(); context.Contract.Id = [SELECT Id FROM ffrr__RevenueContract__c WHERE Name = 'ContractName' LIMIT 1].Id; // If you are creating a new revenue contract, you can leave the Contract property as null, // or, you can specify the following optional fields: // - AccountId // - Description // - CurrencyIsoCode // - SourceRecordId // - StartDate // - EndDate context.Contract.AccountId = [SELECT Id FROM Account WHERE Name = 'AccountName' LIMIT 1].Id; context.Contract.Description = 'Contract for engagement: ENG0000000'; context.Contract.CurrencyIsoCode = 'USD'; context.Contract.SourceRecordId = 'a1B0t000003hS8oEAE'; context.Contract.StartDate = Date.today(); context.Contract.EndDate = Date.today().addMonths(6); Properties
ffrr.RevenueContractService.ManageRevenueContractResultglobal with sharing class ManageRevenueContractResult Contains information resulting from the create or update revenue contract process. Properties
ffrr.RevenueContractService.SaveResultglobal abstract with sharing class SaveResult Contains the results of the Save operation Properties
MethodsSaveResultglobal SaveResult() ffrr.RevenueContractService.SourceReferenceglobal with sharing class SourceReference Contains information about the records found from the Search process. Properties
ffrr.RevenueContractService.TransferContextglobal with sharing class TransferContext @decription The context in which the Transfer Previously Recognized process will be executed. 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 Transfer context to specify how the Transfer Previously Recognized process // will be executed. // Select the period the Recognition Transaction will be created for. Date recognitionDate = Date.newInstance(2016, 1, 1); List<ffrr__RecognitionPeriod__c> periods = [SELECT Id FROM ffrr__RecognitionPeriod__c WHERE ffrr__StartDate__c <= :recognitionDate AND ffrr__EndDate__c >= :recognitionDate]; // Select an "In Progress" Transaction to Update. List<ffrr__RevenueRecognitionTransaction__c> transactions = [SELECT Id FROM ffrr__RevenueRecognitionTransaction__c WHERE ffrr__Status__c = 'In Progress' AND ffrr__Description__c = 'FinancialForce.com' LIMIT 1]; List<Id> transactionIds = new List<Id>(); for( ffrr__RevenueRecognitionTransaction__c trans : transactions ) { transactionIds.add(trans.Id); } // Select the Performance Obligation Line Items related to the source records. Any "Committed" Revenue to be used // Recognition Transaction related to those source records will be taken into account from this proccess. Date startOf2017 = Date.newInstance(2017, 01, 01); List<ffrr__PerformanceObligationLineItem__c> lineItems = [SELECT Id FROM ffrr__PerformanceObligationLineItem__c WHERE ffrr__PerformanceObligation__r.ffrr__RevenueContract__r.ffrr__StartDate__c >= :startOf2017]; List<Id> lineItemIds = new List<Id>(); for( ffrr__PerformanceObligationLineItem__c lineItem : lineItems ) { lineItemIds.add(lineItem.Id); } // Create the Transfer Context. ffrr.RevenueContractService.TransferContext context = new ffrr.RevenueContractService.TransferContext(); // Set the Performance Obligation Line Item Ids to the context. context.PerformanceObligationLineItems = lineitemIds; // Set the transction to be updated. context.TransactionIds = transactionIds; // Specify the Period that will be put on the Recognition Transactions context.Period = periods[0].Id; // Specify the Recognition Date and Description that will be on the Revenue Recognition Transactions context.RecognitionDate = recognitionDate; context.Description = 'Previously recognized before 2016'; // Specify the Cutoff Date that will be used to determine which Transactions will be used to transfer Previously Recognized. context.CutoffDate = Date.newInstance(2015, 12, 31); // Specify the legislation type for the Transactions that will be created. context.LegislationType = 'ASC 605'; // Specify the filter to limit which Performance Obligation Line Items get selected. // For this example we will filter where the Account.Name is 'FinancialForce' ffrr.RevenueContractService.Filter filter = new ffrr.RevenueContractService.Filter(); // Set the field to filter on to be the Description__c field. This could be any text or lookup field. filter.Field = ffrr__RevenueContract__c.ffrr__Account__c; // Set the value to filter on. filter.Value = [SELECT Id FROM Account WHERE Name = 'FinancialForce' LIMIT 1].Id; context.RevenueContractFilters = new List<ffrr.RevenueContractService.Filter>{filter}; Properties
MethodsTransferContextglobal TransferContext() ffrr.RevenueContractService.TransferResultglobal with sharing class TransferResult Properties
|