Concepts


Atarc Process


We must understand the concept o an apex helper class as the atarc process is actually mount on top of it.

An Atarc Process is actually an apex helper class that extends AsyncTriggerArc.AsyncTriggerArcProcessBase or AsyncTriggerArc.AsyncTriggerArcFEAProcessBase apex class designed to perform instructions with specific goal. Additionally a record in the Atarc Process Settings custom metadata type using the apex class must exists.

It should focus only on a single functionality so that we can leverage the ATARC framework phylosophy, this way you will be able to have full control over any feature, meaning that if an atarc process does only one functionality we could EFFECTIVELY do the following as we know we are impacting one functionality:

  • Disabling specific atarc process
  • Upgrading an atarc process to Async mode
  • Control the order of execution
  • Bypass a specific process if needed
  • Implement atarc process dependency if needed

Consider the following atarc process apex helper class:


public class SendRequestEmail extends AsyncTriggerArc.AsyncTriggerArcProcessBase {
    
    protected override object execute(AsyncTriggerArc.AsyncTriggerArcContext triggerContext){
        List accounts = (List) triggerContext.newList;
        List messages =   new List();
        for(Account acc: accounts){
            if(acc.Name == 'Hey') acc.Name = 'Yo';
            if(acc.sendRequestEmail__c){
                Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
                message.toAddresses = new List { 'atarc@atarc.io' };
                message.subject = 'Requesting it';
                message.plainTextBody = 'Requesting from ' +acc.Name;
                messages.add(message);
            }
        }
        List results = new List();
        if(messages.size() > 0) Messaging.sendEmail(messages);
        return null;
            
    }
    
}
    

The previous atarc process perform two functionalities:

  • Changes the name of the account if the current name is 'Hey'.
  • Sends an email to some address if the field sendRequestEmail__c is true.

Now think about this, if this atarc process is disabled its going to shut down two functionalities which is not the idea behind having atarc processes, the idea is that if an atarc process is disabled its only tight to a single functionality thus only that functionality will get affected.

Now let's separate the functionalities so that we have two atarc processes instead of one and each encapsulates a single functionality.


public class SendRequestEmail extends AsyncTriggerArc.AsyncTriggerArcProcessBase {
    
    protected override object execute(AsyncTriggerArc.AsyncTriggerArcContext triggerContext){
        List accounts = (List) triggerContext.newList;
        List messages =   new List();
        for(Account acc: accounts){
            if(acc.sendRequestEmail__c){
                Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
                message.toAddresses = new List { 'atarc@atarc.io' };
                message.subject = 'Requesting it';
                message.plainTextBody = 'Requesting from ' +acc.Name;
                messages.add(message);
            }
        }
        List results = new List();
        if(messages.size() > 0) Messaging.sendEmail(messages);
        return null;
            
    }
    
}
    

public class NameChanger extends AsyncTriggerArc.AsyncTriggerArcProcessBase {
    
    protected override object execute(AsyncTriggerArc.AsyncTriggerArcContext triggerContext){
        List accounts = (List) triggerContext.newList;
        for(Account acc: accounts){
            if(acc.Name == 'Hey') acc.Name = 'Yo';
        }
        return null;
    }
    
}
    

The previous two atarc process apex helper classes are focusing on their own functionalities each. This way, if we disable one the other one is not affected. Of course is not only enabling or disabling, it could be upgrading to async or implementing some process dependencies, as a matter of facts it extends to all the features available in the framework.