FXCallable

Introduction

FXCallable is an Apex class within the FX5 namespace that utilizes Salesforce’s Callable interface.

FXCallable provides one service, OverrideBatcher.

Methods

call(action,args)

Provides functionality to call callable classes inside of the FX package

Signature

public SvcResult call(String action, Map<String,Object> args)

Parameters

  • action

    • Type: String

    • The action is defined by the Service and method from that service. The service and method are delimited by a period(.).

      Example 1. Call the service OverrideBatcher and the method RunOnTickets
      String action = ‘OverrideBatcher.RunOnTickets
  • args

    • Type: Map<String,Object>

    • Arguments to be used by the specified action

Return Value

  • Type: Object

  • Args are defined by the method of the services used. The key is the parameter name. The value is the parameter value.

Using OverrideBatcher Service

If there is no OverrideConfig or Override defined, do not run the OverrideBatcher on a Job or Ticket update.

OverrideBatcher has two Methods

Method Parameters Returns

RunOnJobs

Set<Id>objIds

SvcResult.Result

  • JobId for the batch that was launched

  • 'synchronous' when run in async Apex context

  • 'skipped' when skipped due to settings

RunOnTickets

Example

FXCallable example

public class ProcessOverrides{
	@InvocableMethod(label='Process Overrides' description='Processes Overrides on a job or ticket async' category='Overrides')
	public static void processOverrides(List<ID> idsIn) {
        Set<Id> ticketIds = new Set<Id>();
        Set<Id> jobIds = new Set<Id>();
		for(Id i : idsIn){
            switch on i.getSObjectType().newSObject() {
            	when Job__c j {
                    jobIds.add(i);
                }
 				when Ticket__c t {
                    ticketIds.add(i);
                }
            }
        }
        if(!jobIds.isEmpty()){
            FXCallable callable = new FXCallable();
            SVCResult results = (SVCResult)callable.call('OverrideBatcher.RunOnJobs',new Map<String, Object> {'objIds' => jobIds});
        }
        if(!ticketIds.isEmpty()){
            FXCallable callable = new FXCallable();
            SVCResult results = (SVCResult)callable.call('OverrideBatcher.RunOnTickets',new Map<String, Object> {'objIds' => ticketIds});
        }
	}
}