fferpcore.ffasync_Processglobal 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. } } } EnumsMonitoringTypeThis class specifies the Monitoring Types which are supported by the framework. The supported values are DETAILED and SIMPLE.
Methods
ffasync_Processglobal ffasync_Process() getQueryLocatorglobal abstract Database.QueryLocator getQueryLocator() Return the query locator for your process. Return ValueDatabase.QueryLocator - records to be run for this Process getStepglobal abstract fferpcore.ffasync_Process.Step getStep() Get the step that will be run for each chunk of records. Return ValueStep class instance getLoggingRequirementglobal virtual fferpcore.ffasync_Process.LoggingRequirement getLoggingRequirement() Get the Logging Requirements for current Process. Takes DETAILED as monitoring type and No userField by default. Return ValueFfasync_Process.LoggingRequirement class instance getDescriptionglobal virtual String getDescription() Description of process. Returns Process as process default description if not overrided. Return ValueDescription of process getScopeSizeglobal virtual Integer getScopeSize() Scope size for the batch. The default value is 1. Return ValueScope size for batch getEndOfProcessActionsglobal 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 ValueList of actions to be run after Process Completion fferpcore.ffasync_Process.Stepglobal 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
Stepglobal Step() canRunParallelglobal 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 ValueFlag to decide whether to run the step Parallel or Serial runglobal 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
Return ValueInstance of ProcessResponse, which specifies if all records are processed successfully or failed getExecutionGroupingFieldsglobal 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 ValueList of grouping fields fferpcore.ffasync_Process.LoggingRequirementglobal virtual class LoggingRequirement This class holds the properties specific to the logging requirements of the framework. Methods
LoggingRequirementglobal LoggingRequirement() LoggingRequirementglobal 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. getMonitoringTypeglobal 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 ValueMonitoring Type which should be used by framework- Detailed or Simple getUserFieldglobal 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 ValueField that specifies the source record user |