Foundations Apex API Developer Reference

fferpcore.ffasync_ProcessService

global with sharing class ffasync_ProcessService

The service class used to perform background processing operations on the supplied processes.

Methods

hasProcessCompleted

global static void hasProcessCompleted(Id processRunId, fferpcore.ffasync_ProcessService.ICallback callBack)

Supports checking whether a process has completed. IMPORTANT the call back may occur in a different apex transaction, as checking some processes with many records could require more querying than can be done in a single apex call due to governor limits.

Input Parameters

Name Type Description
processRunId Id ID of the ProcessRun record which is being tested. If the process was simple monitoring then will be a basic check that may provide the correct answer, but other wise an exception will thrown.
callBack fferpcore.ffasync_ProcessService.ICallback A call back that will be notified of whether the process run has completed or not. response type of the argument on that callback will be Boolean.

addProcess

global static void addProcess(fferpcore.ffasync_ProcessService.ProcessExecutionContext ctxt, fferpcore.ffasync_Process process)

Supports adding a process into an existing run. The result of this will depend on whether the existing run is part of a chained process or not. In a chained process the new process will be added to the end of the chain. if the existing process was not a chained version, but a single call then this will result in a new single process run after the current one. a new parent process run will not be created and so on. See fferpcore.ffasync_ProcessService.AddProcess class for an fferpcore.ffasync_IAction that can be returned by a process that will handle calling this.

Input Parameters

Name Type Description
ctxt fferpcore.ffasync_ProcessService.ProcessExecutionContext The context of the current process.
process fferpcore.ffasync_Process The new process to be ran later.

addProcess

global static void addProcess(fferpcore.ffasync_ProcessService.ProcessExecutionContext ctxt, fferpcore.ffasync_ProcessIterable process)

Input Parameters

Name Type Description
ctxt fferpcore.ffasync_ProcessService.ProcessExecutionContext The context of the current process.
process fferpcore.ffasync_ProcessIterable The new process to be ran later.

startProcess

global static Id startProcess(fferpcore.ffasync_Process process)

Supports single process jobs.

Input Parameters

Name Type Description
process fferpcore.ffasync_Process Instance of ffasync_Process class to be processed

Return Value

ProcessRun ID of the Process Run Record

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.

fferpcore.ffasync_Process p = new SampleProcess();
fferpcore.ffasync_ProcessService.startProcess(p); //works for single Process Run

startProcess

global static Id startProcess(fferpcore.ffasync_ProcessIterable process)

Input Parameters

Name Type Description
process fferpcore.ffasync_ProcessIterable Instance of ffasync_ProcessIterable class to be processed

Return Value

ProcessRun ID of the Process Run Record

startChainedProcesses

global static Id startChainedProcesses(fferpcore.ffasync_ChainedProcess cProcess)

Supports multiple processes. The processes supplied in the list are chained together and run in sequence.

Input Parameters

Name Type Description
cProcess fferpcore.ffasync_ChainedProcess Instance of ffasync_ChainedProcess class

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.

fferpcore.Process p = new SampleProcess();
String parentDescription = 'Background Posting';
List<fferpcore.ffasync_IAction> actions = new List<fferpcore.ffasync_IAction>{new CustomAction()};// CustomAction will implement ffasync_IAction interface
fferpcore.ffasync_ChainedProcess cProcess = new fferpcore.ffasync_ChainedProcess(new List<fferpcore.ffasync_Process>{p}, parentDescription, actions);
fferpcore.ffasync_ProcessService.startChainedProcesses(cProcess);

fferpcore.ffasync_ProcessService.ProcessResponse

global inherited sharing class ProcessResponse

The service class used to handle responses from Process. The results of records in each Process Run are held in RecordStatus, and the list used to build a single response object for each Process Run.

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.

Id recordId; //Id of the record to be run in Process e.g. worker item in Background Posting
Boolean isSuccessful = true; //false if processing failed.
Id relatedRecordId; //Id of the related record of running record e.g. Sales Invoice
String message = 'success'; // Message to identify success or failure of record.
fferpcore.ffasync_ProcessService.RecordStatus recordStatus = new fferpcore.ffasync_ProcessService.RecordStatus(recordId, isSuccessful, relatedRecordId, message);
List<fferpcore.ffasync_ProcessService.RecordStatus> recordStatuses = new List<fferpcore.ffasync_ProcessService.RecordStatus>{recordStatus};
fferpcore.ffasync_ProcessService.ProcessResponse response = new fferpcore.ffasync_ProcessService.ProcessResponse(recordStatuses);

Methods

ProcessResponse

global ProcessResponse()

ProcessResponse

global ProcessResponse(List<fferpcore.ffasync_ProcessService.RecordStatus> recordStatuses)

Input Parameters

Name Type Description
recordStatuses List<fferpcore.ffasync_ProcessService.RecordStatus> List of RecordStatus class instance

fferpcore.ffasync_ProcessService.RecordStatus

global inherited sharing class RecordStatus

Holds information on the Status of each record in the Process Run

Methods

RecordStatus

global RecordStatus(Id recordId, Boolean isSuccessful, Id relatedRecordId, String message)

Input Parameters

Name Type Description
recordId Id ID of the record to be processed
isSuccessful Boolean Indicates whether processing was successful. The log status is marked OK if this value is True, and Error if this is False. The log status remains unchanged if this value is null.
relatedRecordId Id [Optional] ID of the related record
message String [Optional] Error/Success messages

RecordStatus

global RecordStatus(Id recordId, Boolean isSuccessful)

Input Parameters

Name Type Description
recordId Id ID of the record to be processed
isSuccessful Boolean Flag to know if processing was successful

fferpcore.ffasync_ProcessService.IProcessResult

global Interface IProcessResult

The runAction method of fferpcore.ffasync_IAction uses this class as input. This class provides information on the results of Process Runs, such as the number of records with Error, Success or Pending status, and the Process Run 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.

public class CustomAction implements fferpcore.ffasync_IAction
{
    public void runAction(fferpcore.ffasync_ProcessService.ProcessExecutionContext ctxt, fferpcore.ffasync_ProcessService.IProcessResult processResult)
    {
        System.debug(result.getErrorCount());
    }
}

Methods

getErrorCount

Integer getErrorCount()

Return Value

Count of error records associated with specified Process Run

getSuccessCount

Integer getSuccessCount()

Return Value

Count of success records associated with specified Process Run

getPendingCount

Integer getPendingCount()

Return Value

Count of pending records associated with specified Process Run

getTotalCount

Integer getTotalCount()

Return Value

Count of total records associated with specified Process Run

getProcessRunId

Id getProcessRunId()

Return Value

ID of Process Run

getUserGroups

List<ProcessUserGroup__c> getUserGroups()

Return Value

List of Process User Groups associated with specified Process Run

getDescription

String getDescription()

Return Value

Returns description of Process Run

useDetailedMonitoring

Boolean useDetailedMonitoring()

Return Value

Returns true if Process ran in detailed monitoring or not

fferpcore.ffasync_ProcessService.NotificationData

global inherited sharing class NotificationData

The class used for input data to the different Notification types, such as Task, Chatter and Email.

Methods

NotificationData

global NotificationData(Set<Id> recipientUserIds, String appName)

Input Parameters

Name Type Description
recipientUserIds Set<Id> Set of IDs of Users who are supposed to receive Notification.
appName String Application Name to be displayed in Notification.

NotificationData

global NotificationData(Set<Id> recipientUserIds)

Input Parameters

Name Type Description
recipientUserIds Set<Id> List of IDs of Users who are supposed to receive Notification.

getAppName

global String getAppName()

Return Value

AppName Application Name to be given in all Notification.

getRecipientUserIds

global Set<Id> getRecipientUserIds()

Return Value

List of IDs of Users who are supposed to receive Notification.

fferpcore.ffasync_ProcessService.AddProcess

global inherited sharing class AddProcess implements ffasync_IAction

Class to be used if user wants to introduce any dynamic process as an action in the end of some process. this as an action at the end of a process will handle everything to do with adding a process dynamically. ffasync_ProcessService.addProcess(ffasync_ProcessService.ProcessExecutionContext ctxt, fferpcore.ffasync_IProcess process) will not be needed when using this.

This class implements the following interfaces:

Methods

AddProcess

global AddProcess(fferpcore.ffasync_Process process)

Input Parameters

Name Type Description
process fferpcore.ffasync_Process Process to be added as a dynamic process in the end of current process

AddProcess

global AddProcess(fferpcore.ffasync_ProcessIterable process)

fferpcore.ffasync_ProcessService.ProcessExecutionContext

global inherited sharing class ProcessExecutionContext

This class contains information that needs to be passed around the system, and can be passed back into the service by custom implementations mid process.

This class contains deprecated items.

Methods

getParentRunId

global Id getParentRunId()

Return Value

ID of the parent ProcessRun__c for the current process. NB this may be null if there isn't one.

getRunId

global Id getRunId()

Return Value

ID of the current ProcessRun__c

Deprecated

The following items are deprecated and not supported for use. We recommend that you stop using these items to avoid exceptions.

Methods

getRecordIds

Deprecated: Deprecated: It has been marked deprecated and throws an exception.

global List<Id> getRecordIds()

Return Value

RecordIDs List of IDs of record executing in this chunk.

fferpcore.ffasync_ProcessService.ICallback

global interface ICallback

Methods

run

void run(Object response)

© Copyright 2009–2023 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.