With processRevenueRun API, you can submit and process a Revenue Run programmatically. For details on Revenue Run batch job, refer to Revenue Run

RevenueRunOutputWrapper processRevenueRun(RevenueRunInputWrapper revRunInput)

This API accepts a RevenueRunInput custom wrapper class as an input parameter. It returns a RevenueRunOutput class. 

Request Parameters

Request - RevenueRunInputWrapper
FieldTypeRequiredDescription
revenueRunObjRevenueRun__cYesA new revenue run object with a unique name.
legalEntityIdIdYes

Id of an active Legal Entity associated with a RevRec Period.

Note: The Current Period Date of the RevRec Period cannot be null.

searchCriteriaListList<RevenueRunSearchCriteriaWrapper>NoSet it to null to process all the records.
searchCriteriaRelation

String

No

filterRelation is required if you have provided a list of search filters.

For example: (1 AND 2)

RevenueRunSearchCriteriaWrapper
FieldTypeRequiredDescription
rowNumIntegerNoThe sequence number of filter criteria. If you do not specify a sequence number, the filter criteria is evaluated in the sequence of data that you provide.
fieldNameString
API Name of the Field. Currently, only the Account field is accepted.
compOperatorString

The comparison operator.

Note: All the comparison operators available on the Revenue Run are accepted.

fieldValueString
The field value.

Response Parameters

Response - RevenueRunWrapperOutput
FieldTypeDescription
revenueRunIdIdId of the newly created Revenue Run. revenueRunId is set as null if the revenue run API is not processed successfully.
revenueRunResultIdIdId of the newly created Revenue Run Result. revenueRunResultId is set as null if the revenue run API is not processed successfully.
messageStringValidation Message.
isSuccess

Boolean

Value is set to true if the Revenue Run is processed successfully.

Value is set to false if the Revenue Run processing fails.


Code Sample

 Apttus_Revenue2.CustomClass.RevenueRunInputWrapper revRunInput = new Apttus_Revenue2.CustomClass.RevenueRunInputWrapper();  
 		revRunInput.revenueRunObj = new Apttus_Revenue2__RevenueRun__c(
        Name = 'testRRR_Test',
        Apttus_Revenue2__JobType__c = 
                'Generate Forecasts',
        Apttus_Revenue2__RunType__c = 'Scheduled'
        );
    revRunInput.legalEntityId = 'a6LW00000001CAP';
    Apttus_Revenue2__RevenueRun__c revRun = revRunInput.revenueRunObj;
    revRunInput.searchCriteriaList = new List<Apttus_Revenue2.CustomClass.RevenueRunSearchCriteriaWrapper>();
    Apttus_Revenue2.CustomClass.RevenueRunSearchCriteriaWrapper sc = new Apttus_Revenue2.CustomClass.RevenueRunSearchCriteriaWrapper();
   	sc.fieldName  = 'Name';
    sc.compOperator   = 'equal to';
    sc.fieldValue = 'RC_Test_Account';
    revRunInput.searchCriteriaList.add(sc);
    sc = new Apttus_Revenue2.CustomClass.RevenueRunSearchCriteriaWrapper(); 
    sc.fieldName  = 'BillingCity';
    sc.compOperator   = 'equal to';
    sc.fieldValue = 'RC_Test_Account';
    revRunInput.searchCriteriaList.add(sc);
    revRunInput.searchCriteriaRelation = '(1 OR 2)';
    // scheduled run data
    revRun.Apttus_Revenue2__PeriodStartDate__c = Date.today();
    revRun.Apttus_Revenue2__PeriodEndDate__c = revRun.Apttus_Revenue2__PeriodStartDate__c.addDays(2);
    revRun.Apttus_Revenue2__ScheduleType__c = 'Monthly by day';
    revRun.Apttus_Revenue2__MonthlyWeek__c = 'the 4th';
    revRun.Apttus_Revenue2__MonthlyWeekDay__c = 'Monday';
    revRun.Apttus_Revenue2__PreferredStartHour__c = '4 PM';
    revRun.Apttus_Revenue2__PreferredStartMinute__c = '30';
    Apttus_Revenue2.CustomClass.RevenueRunOutputWrapper revRunOutput = Apttus_Revenue2.RevRecAction.processRevenueRun(revRunInput);
    System.debug('revRunOutput: ' + revRunOutput);
// Sample output:
// revRunOutput: RevenueRunOutputWrapper:[isSuccess=true, message=null, revenueRunId=a6QW00000002Ss5MAE, revenueRunResultId=null]
CODE