PSA Apex API Developer Reference

pse.APICommonsService

global with sharing class APICommonsService

Enums

BatchJobType

Value Description
Clear FinancialForce PSA billing process to clear billing data for billing event items, billing events, budgets, expense reports, expenses milestones, miscellaneous adjustments, timecard splits and timecards.
Generate FinancialForce PSA billing process to generate billing data.
Invoice FinancialForce PSA billing process to invoice billing events.
Recalc FinancialForce PSA billing process to recalculate the billing information for unreleased billing events.
Release FinancialForce PSA billing process to release billing events.
Remove FinancialForce PSA billing process to remove billing event batches.

pse.APICommonsService.iBatchCallback

global interface iBatchCallback

You can use the iBatchCallback global interface to hook into FinancialForce PSA billing processes such as:
• Clear
• Generate
• Invoice
• Release
• Remove
These interface hooks are called during FinancialForce PSA billing processes and each method is called even when a process is executed inline rather than as a batch. To use these hooks, you must write classes that implement the iBatchCallback interface. Once you have written a class to handle a billing process, you must instruct FinancialForce PSA to use it. To do this, add a value containing the name of your class to the appropriate billing Interface configuration option in the Billing configuration group. For information about configuring FinancialForce PSA to use a custom billing class, see the FinancialForce PSA Help.

Methods

beforeStart

void beforeStart(pse.APICommonsService.BatchContext bc)

This method is called before the logic of the Start method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the 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.

global void beforeStart(pse.APICommonsService.BatchContext bc){} 

afterStart

void afterStart(pse.APICommonsService.BatchContext bc)

This method is called after the logic of the Start method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the 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.

global void afterStart(pse.APICommonsService.BatchContext bc){}

beforeExecute

void beforeExecute(pse.APICommonsService.BatchContext bc, set<ID> scope)

This method is called before the logic of the Execute method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the job.
scope set<ID> Contains the IDs of the records being processed in a specific batch.

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.

global void beforeExecute(pse.APICommonsService.BatchContext bc, Set<ID> scope){} 

afterExecute

void afterExecute(pse.APICommonsService.BatchContext bc, set<ID> scope)

This method is called after the logic of the Execute method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the job.
scope set<ID> Contains the IDs of the records being processed in a specific batch.

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.

beforeFinish

void beforeFinish(pse.APICommonsService.BatchContext bc)

This method is called before the logic of the Finish method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the 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.

global void beforeFinish(pse.APICommonsService.BatchContext bc){}

afterFinish

void afterFinish(pse.APICommonsService.BatchContext bc)

This method is called after the logic of the Finish method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the 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.

global void afterFinish(pse.APICommonsService.BatchContext bc){
  BillingContext bbc = (BillingContext)bc;
 
  appirio_core__Config_Value__c cv = [SELECT id,appirio_core__Value__c
    FROM appirio_core__Config_Value__c
    WHERE appirio_core__Config_Option__r.Name = 'nextInvoiceNumber'
    ];
 
    Integer invNum = Integer.valueOf(cv.appirio_core__Value__c);
 
    List<pse.BillingEventsManager.InvoiceInfo> invoiceInfo = new List<pse.BillingEventsManager.InvoiceInfo>();
    for (ID id : bbc.ids)
    {
      pse.BillingEventsManager.InvoiceInfo ii = new pse.BillingEventsManager.InvoiceInfo(id,String.ValueOf(invNum),Date.today());
      invoiceInfo.add(ii);
      invNum++;
    }
    cv.appirio_core__Value__c = String.ValueOf(invNum);
    update cv;
 
    pse.APIBillingService.Invoice(invoiceInfo);
}

getJobType

BatchJobType getJobType()

This method must be implemented by the creator of any class that implements the iBatchCallback interface. This indicates the FinancialForce PSA billing process that the class is to intends to implement. These FinancialForce PSA billing processes all confirm that the implemented type matches their identity:
• Clear
• Generate
• Invoice
• Recalc
• Release
• Remove

Return Value

This method returns an APICommonsService.BatchJobType object.

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.

global pse.APICommonsService.BatchJobType getJobType(){return pse.APICommonsService.BatchJobType.Release;}

pse.APICommonsService.BatchContext

global abstract class BatchContext

BatchContext contains information about the context of the job. This is specific to each process and is based on the information used to launch that process.

Properties

Name Type Description
context Database.BatchableContext Information about the context of the job.
jobType pse.APICommonsService.BatchJobType Action being carried out for the job.

pse.APICommonsService.BatchStatus

global class BatchStatus

Contains the status, error message and batch ID of a job.

Properties

Name Type Description
status String Contains the status of the API request:
• Completed means that the job was not sent to a batch, but was done inline and was successful.
• Error means that an error occurred. The error message field contains an error message.
• Batched implies that the job was successfully submitted as a batch job. The batchID contains the ID of the job.
errorMessage String Action being carried out for the job.
jobID ID Contains the ID of the batch if it was successfully submitted as a batch. jobID must be specified if you want to retrieve the status of a batch.

Methods

BatchStatus

global BatchStatus(String status, String errorMessage, ID jobID)

© Copyright 2009–2020 FinancialForce.com, inc. Confidential – all rights reserved. Various trademarks held by their respective owners.