API Reference


Apex Classes

AsyncTriggerArc apex class

This apex class is the core of the framework. It is the responsible of getting the list of processes to run, ordering, managing the execution dependency and everything related to the framework.

Public Constructors

AsyncTriggerArc()

        AsyncTriggerArc atarc = new AsyncTriggerArc();
    
AsyncTriggerArc(boolean isBefore, boolean isAfter, boolean isInsert, boolean isUpdate, boolean isDelete, boolean isUndelete, List<SObject> newList, List<SObject> oldList, Map<Id, SObject> newMap, Map<id,SObject> oldMap)

        AsyncTriggerArc atarc = new AsyncTriggerArc(
        trigger.isBefore,
        trigger.isAfter,
        trigger.isInsert,
        trigger.isUpdate,
        trigger.isDelete,
        trigger.isUndelete,
        trigger.new,
        trigger.old,
        trigger.newmap,
        trigger.oldmap);
    
AsyncTriggerArc(string sObjectName, boolean isBefore, boolean isAfter, boolean isInsert, boolean isUpdate, boolean isDelete, boolean isUndelete, List newList, List oldList,Map<Id, SObject> newMap, Map<id,SObject> oldMap)

        AsyncTriggerArc atarc = new AsyncTriggerArc('Opportunity',
        trigger.isBefore,
        trigger.isAfter,
        trigger.isInsert,
        trigger.isUpdate,
        trigger.isDelete,
        trigger.isUndelete,
        trigger.new,
        trigger.old,
        trigger.newmap,
        trigger.oldmap);
    

Public Static Variables

Name
Data Type
Description
PROCESS_EXECUTED
string
Constant value, represents an atarc process status of "Executed"
PROCESS_FAILED
string
Constant value, represents an atarc process status of "Failed"
CATEGORY_SKIP
string
Constant value, represents "category" value use in the bypass api.
OBJECT_SKIP
string
Constant value, represents "object" value use in the bypass api.
EVENT_SKIP
string
Constant value, represents "event" value use in the bypass api.
PROCESS_SKIP
string
Constant value, represents "process" value use in the bypass api.
FRAMEWORK_NAME
string
Constant value, represents "ATARC" value framework name use by the debug mechanism.
GOVERNOR_LIMITS_QUEUEABLE
string
Constant value, salesforce's max number of enqueueJob calls in a transaction.
globalSkip
boolean
If true, no atarc processes is executed. You can set this value with the 'SkipAll' field from the custom setting ATARC Global Setting. Think of this as a global bypass.
globalDebugMode
boolean
Use this if you want to silent ATARC's debug general info. You can set this value with the "debug" from the custom setting ATARC Global Setting.

Public Static Methods

Name
Parameters
Returns
Description
debug
msg, object
void
Use this method instead of system.debug in order to print anything to the debug output, the framework may determine to print or not if the running process has the debug mode flag set to true. This is very powerful since debugs may be dynamically turned on or off from the ATARC Process Settings.

Public Instance Methods

Name
Parameters
Returns
Description
Start
void
Starts the atarc engine. Must call from within a trigger.
getProcessesExecutionInformation
Map<string, AsyncTriggerArc.AsyncTriggerArcProcessInfo>
Returns a map where the key is the process name and the value is an instance of the type AsyncTriggerArc.AsyncTriggerArcProcessInfo. It provides information of the status of a process.

AsyncTriggerArc.AsyncTriggerArcProcessInfo apex class

An instance of this class holds information about specific process. Calling the AsyncTriggerArc.getProcessesExecutionInformation() will return a map where the key is a process name and the value is an instance of this class.


        //...
        Map<string, AsyncTriggerArc.AsyncTriggerArcProcessInfo>  processesInfo = AsyncTriggerArc.getProcessesExecutionInformation();
       // ...
    

Public Instance Properties

Name
Data Type
Description
status
string
The status of the process, possible values: Executed, Failed
processTime
decimal
The time in milliseconds the process took to finish.

AsyncTriggerArc.AsyncTriggerArcContext apex class

This is a very important class. An instance of this apex class is passed by the ATARC engine to the execute method of the apex class extending the base class AsyncTriggerArc.AsyncTriggerArcProcessBase or to the >filter, action or execute methods of an apex class extending the base class AsyncTriggerArc.AsyncTriggerArcFEAProcessBase. It contains most of the context variables you can see in the standard trigger variable within a transaction.

Public Instance Methods

Name
Parameters
Returns
Description
getProcessData
processName, string, this is the name of a process from the ATARC Process Setting
object
This method let's you get the output of a process. The output is actually the value returned from the execute method of the base class AsyncTriggerArc.AsyncTriggerArcProcessBase or AsyncTriggerArc.AsyncTriggerArcFEAProcessBase. One can pass data from a process to another by leveraging this method.
getCurrentProcessName
string
Returns the name of the current process that actually executed the apex class ( atarc process ).
getProcessStatus
processName, string, this is the name of a process from the ATARC Process Setting
string
Returns the status of a given process. The possible return values are Executed, Failed or null. If the process has not been called yet, the return value is null.
setFailed
void
Set the current processes status as Failed.
bypass
skipType, string, This value represents the type of skip we want to do. The accepted list of values is the following: category, object, event, process. skipValue, this is the value respective to the skipType you choose. For instance if you want to skip specific process then skipValue should be the name of the process defined in the ATARC Process Setting.
AsyncTriggerArcContext
Adds a bypass for a specific category or object, or event or process.
clearBypass
skipType, string, This value represents the type of skip we want to clear. The accepted list of values is the following: category, object, event, process. skipValue, this is the value respective to the skipType you choose to clear.
AsyncTriggerArcContext
Clears a bypass for a specific skip type.
debug
msg, object
void
Use this method instead of system.debug in order to print anything to the debug log, the framework may print or not if the running process has debug mode flat set to true. This is powerful since debugs can be turned on or off dynamically.

Public Instance Properties

Name
Data Type
Description
IsBefore
boolean
True if it runs within a trigger attached to a before event.
IsAfter
boolean
True if it runs from within a trigger attached to an after event
IsInsert
boolean
True if it runs from within a trigger attached to a insert event
IsUpdate
boolean
True if it runs from within a trigger attached to an update event.
IsDelete
boolean
True if it runs from within a trigger attached to a delete event.
IsUnDelete
boolean
True if it runs from within a trigger attached to a undelete event.
newList
List<SObjet>
Similar to trigger.new. It contains a list of records which are the initiators of the DML that fired the trigger events.
newMap
Map<Id, SObject>
Similar to trigger.newmap, It contains a map of records which are the initiators of the DML that fired the triggers events.
oldList
List<SObjet>
Similar to trigger.old.,It contains a list of records which are the previous state of the records within the newList property.
oldMap
Map<Id, SObject>
Similar to trigger.oldmap.,It contains a list of records which are the previous state of the records within the newMap property.
LoopLimit
integer
When a value is set, it can control the how many times a process is executed within recursive transactions even if the ATARC Process Setting's "Override Loop Limit" field is false.

AsyncTriggerArc.AsyncTriggerArcProcessBase apex class

Any class extending this abstract class will become ATARC compliant, this means, it can be used as an atarc process by having a record in the ATARC Process Setting custom metadata type. It only contains a simple method to override, execute which is invoked only once by ATARC in the ideal scenario.

If any constructor is defined, the class must have at least one parameter less constructor, no constructor defined is also acceptable.


public class NameChanger extends AsyncTriggerArc.AsyncTriggerArcProcessBase {

    /*
        this method is meant to be called once
    */
    protected override object execute(AsyncTriggerArc.AsyncTriggerArcContext triggerContext)
    {  
        
        List<Opportunity> ops = (List<Opportunity>)triggerContext.newList;

        for(Opportunity op : ops.values()){
            op.Name = ' name changer ';
        }

        return null;

    }

}
    

The engine will provide an instance of AsyncTriggerArc.AsyncTriggerArcContext so that the developer use it as it was working from within a trigger.

AsyncTriggerArc.AsyncTriggerArcFEAProcessBase apex class

Any class extending this abstract class will become ATARC compliant, this means, it can be used as an atarc process by having a record in the ATARC Process Setting custom metadata type. This one contains three methods filter, execute and action. This is actually following the FEA pattern.

If any constructor is defined, the class must have at least one parameterless constructor, no constructor defined is also acceptable.


public class OpportunityValidatorProcess extends AsyncTriggerArc.AsyncTriggerArcFEAProcessBase {

    set<id> filteredOpportunities = new set<id>();
    set<id> opptiesShouldAddError = new set<id>();

    /*
        this metod should be executed once per record before execute and action.
    */
    protected override void filter(sObject newRecord, sObject oldRecord, AsyncTriggerArcContext triggerContext){
         Opportunity newOppty = (Opportunity) newRecord;
         Opportunity oldRecord = (Opportunity) oldRecord;
         
         if(newOppty.stageName != oldOppty.stageName)
            filteredOpportunities.add(newOppty.id);
    }

    /*
        this method should be executed once after filter and before action
    */
    protected override object execute(AsyncTriggerArc.AsyncTriggerArcContext triggerContext)
    {  
         if(filteredOpportunities.size() > 0){

          //do something with the opportunities filtered in the action method
           opptiesShouldAddError  = ExampleHelper.getOpptiesToError(filteredOpportunities);
         }
           

        return null;

    }

    /*
        this method should be executed once per record after filter and action
    */
   protected override void action(sObject newRecord, sObject oldRecord, AsyncTriggerArcContext triggerContext){
         Opportunity newOppty = (Opportunity) newRecord;
         Opportunity oldRecord = (Opportunity) oldRecord;
         
         if(newOppty.stageName != oldOppty.stageName && opptiesShouldAddError.contains(newOPpty.Id))
            newOppty.addError('This oppty should not be created');
    }

}