Foundations Apex API Developer Reference

fferpcore.ffasync_Process

global abstract class ffasync_Process implements ffasync_IProcess

This class is the main entry point for the system. It must be implemented.

This class implements the following interfaces:

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 SampleProcess extends fferpcore.ffasync_Process
{
    // All overrided methods and their definitions will be here including required constructors. For e.g.
    // To provide process description
    global override String getDescription()
    {
        return 'Sample Description'; // Description of the process.
    }

    // Returns the query locator for the process.
    global override Database.QueryLocator getQueryLocator()
    {
        // retrun Database.QueryLocator instance. Below is an example.
        return Database.getQueryLocator('SELECT AccountNumber FROM Account');
    }

    //Logging Requirements of the framework which controls different logging parameters
    // can be specified using LoggingRequirement Class.
    // It is optional to override this method. Default behavior is DETAILED MonitoringType
    // with null userField. User can optionally override this method and provide custom
    // implementation using parameterized constructor of fferpcore.ffasync_Process.LoggingRequirement class.
    // Or user can extend fferpcore.ffasync_Process.LoggingRequirement and provide definitions of two getters.
    global override fferpcore.ffasync_Process.LoggingRequirement getLoggingRequirement()
    {
        //Below code uses framework provided class's parameterized constructor and this way
        // it avoids creating a new class extending ffasync_Process.LoggingRequirement
        return new fferpcore.ffasync_Process.LoggingRequirement(fferpcore.ffasync_Process.MonitoringType.DETAILED, Account.OwnerId);
    }

    //Scope size for the batch.
    global override Integer getScopeSize()
    {
        return 1;
    }

    //Some custom actions can be run after fferpcore.Process completion. For example, email or task 
    // notifications can be generated to inform users that fferpcore.Process has completed.
    global override List<fferpcore.ffasync_IAction> getEndOfProcessActions()
    {
        return new List<fferpcore.ffasync_IAction>{new CustomAction()};// CustomAction will implement fferpcore.ffasync_IAction interface
    }

    // Need to also have a Step to perform task
    public class SampleStep extends fferpcore.ffasync_Process.Step
    {
        // required methods will be overrided here e.g.
        // To run steps parallely or serially
        global override Boolean canRunParallel()
        {
            return true;// false for serial processing
        }

        global override List<SObjectField> getExecutionGroupingFields()
        {
            return new List<SObjectField>{Account.Name}; // field should be namespaced
        }

        global override fferpcore.ffasync_ProcessService.ProcessResponse run(fferpcore.ffasync_ProcessService.ProcessExecutionContext ec, List<Id> recordsIds)
        {
            // code for processing on the basis of recordIds.
        }
    }
}

Enums

MonitoringType

This class specifies the Monitoring Types which are supported by the framework. The supported values are DETAILED and SIMPLE.

Value Description
DETAILED Detailed Monitoring creates Process Log records, [optionally] Process User Group records and provides processed items success and failure counts.
SIMPLE Simple Monitoring does not create Process Logs records, Process User Group records or provide processed items success or failure counts. It is comparatively faster than Detailed monitoring if all other parameters are the same.

Methods

ffasync_Process

global ffasync_Process()

getQueryLocator

global abstract Database.QueryLocator getQueryLocator()

Return the query locator for your process.

Return Value

Database.QueryLocator - records to be run for this Process

getStep

global abstract fferpcore.ffasync_Process.Step getStep()

Get the step that will be run for each chunk of records.

Return Value

Step class instance

getLoggingRequirement

global virtual fferpcore.ffasync_Process.LoggingRequirement getLoggingRequirement()

Get the Logging Requirements for current Process. Takes DETAILED as monitoring type and No userField by default.

Return Value

Ffasync_Process.LoggingRequirement class instance

getDescription

global virtual String getDescription()

Description of process. Returns Process as process default description if not overrided.

Return Value

Description of process

getScopeSize

global virtual Integer getScopeSize()

Scope size for the batch. The default value is 1.

Return Value

Scope size for batch

getEndOfProcessActions

global virtual List<fferpcore.ffasync_IAction> getEndOfProcessActions()

Some custom actions can be run after Process completion. For example, email or task notifications can be generated to inform users that Process has completed. By default no action will be added.

Return Value

List of actions to be run after Process Completion

fferpcore.ffasync_Process.Step

global abstract class Step implements ffasync_IProcessStep

A step is the work that is to be done on each chunk of records that we have, e.g. a batch execute or a qeueueable execute.

This class implements the following interfaces:

Methods

Step

global Step()

canRunParallel

global virtual Boolean canRunParallel()

Steps can be executed serially or in parallel. If set to False, the step runs serially. The default value is True, to run the step in parallel.

Return Value

Flag to decide whether to run the step Parallel or Serial

run

global abstract fferpcore.ffasync_ProcessService.ProcessResponse run(fferpcore.ffasync_ProcessService.ProcessExecutionContext ec, List<Id> recordsIds)

This will be called by the async job for the main task and returns ffasync_ProcessService.ProcessResponse. This will be called by the async job, it could be a batch, queueuable etc.

Input Parameters

Name Type Description
ec fferpcore.ffasync_ProcessService.ProcessExecutionContext Execution Context for running the process.
recordsIds List<Id> The IDs of the records to process.

Return Value

Instance of ProcessResponse, which specifies if all records are processed successfully or failed

getExecutionGroupingFields

global virtual List<SObjectField> getExecutionGroupingFields()

Used to group records by a grouping key and only run a set of records from that group in any one execution. This is useful for things such as FFA company handling, where all records must be in the same company for a given service call and the process may pick up records from many companies. Returns null as default value.

Return Value

List of grouping fields

fferpcore.ffasync_Process.LoggingRequirement

global virtual class LoggingRequirement

This class holds the properties specific to the logging requirements of the framework.

Methods

LoggingRequirement

global LoggingRequirement()

LoggingRequirement

global LoggingRequirement(fferpcore.ffasync_Process.MonitoringType monitoringType, SObjectField userField)

This parameterized constructor enables users to create a LoggingRequirement instance with minimal code without extending the LoggingRequirement class. The default value for MonitoringType is DETAILED and the default value for userField is Null. This default behavior is provided to users unless they override the getLoggingRequirement() method in the Process class. Users can still extend the LoggingRequirement class to provide custom valid values for MonitoringType and UserField.

getMonitoringType

global virtual fferpcore.ffasync_Process.MonitoringType getMonitoringType()

There are currently two Monitoring Types you can use, Simple and Detailed. Simple monitoring, which is light and fast, does not generate Process Logs or details about the failure or success of processes. Detailed monitoring generates the Process Logs and detailed information about failure or success of the processes. To enable detailed monitoring, DETAILED must be returned from this method. The system runs in detailed mode by default.

Return Value

Monitoring Type which should be used by framework- Detailed or Simple

getUserField

global virtual SObjectField getUserField()

This field specifies the user that will be notified when the process ends. It can be used to create a custom relationship between records and a user. If this field is specified, then there will be changes in the logging. Records will be created in the database for each UserGroup i.e. groups of source object records on the basis of UserField. This field could be createdByID or another field containing a lookup to user ID on the source object. By default it returns null.

Return Value

Field that specifies the source record user

© Copyright 2009–2022 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.