Skip to content

Latest commit

 

History

History
216 lines (130 loc) · 4.08 KB

File metadata and controls

216 lines (130 loc) · 4.08 KB

This class contains two inner classes used for testing the QueueableProcess framework.

Fields

handleExceptionCalled

TESTVISIBLE

A 'circuit breaker' to be tripped when the handle exception method is called. This is only used for testing.

Signature

private static handleExceptionCalled

Type

Boolean

Methods

fetchAccountByIdForDemoPurposes(accountId)

A de-duplication effort to fetch the account by ID. Used only by this class' examples.

Signature

public static Account fetchAccountByIdForDemoPurposes(Id accountId)

Parameters

Name Type Description
accountId Id Id account id to fetch.

Return Type

Account

Account returns the account object referenced by id.

Classes

Step1 Class

Step1 is an inner class that conforms to QueueableProcess. It represents an example step in a process that updates an account's shipping street. It also increments the data passthrough by 1.

Fields

accountId

The Account Id to work with

Signature
private final accountId
Type

Id

Constructors

Step1()

SUPPRESSWARNINGS

This is a required no-arg/no-opp constructor. When/if the class is instantiated by the error handler, this constructor is used.

Signature
public Step1()

Step1(accountId)

The normal constructor. Accepts a accountId.

Signature
public Step1(Id accountId)
Parameters
Name Type Description
accountId Id Id the account id to process.

Methods

execute()

This is the main execute method required by the QueueableProcess abstract class. This is where developers will place the code to execute asynchronously in this step. In this case, all it does is fetch an account and increment the shipping street by 1. #riviting.

Signature
public override void execute()
Return Type

void


handleException(e)

This is an optionally overridable method from the QueueableProcess abstract class. If this method is defined on your class, should the execute method above fail at runtime, the QueueableProcess finalizer will instantiate this class, and call this method. This allows developers to write per-step customized error handling. In this case, we're just setting a static boolean to true so we can test the functionality.

Signature
public override void handleException(Exception e)
Parameters
Name Type Description
e Exception Exception any exception object.
Return Type

void

Step2 Class

This is a second example of a QueueableProcess step. It's very similar to the first, but it manipulates the account phone field.

Fields

accountId

The Account Id to work with

Signature
private final accountId
Type

Id

Constructors

Step2()

SUPPRESSWARNINGS

a no-arg/no-opp constructor. This is required for the QueueableProcess framework to be instantiated dynamically should an error condition occur during the execution of the process.

Signature
public Step2()

Step2(accountId)

Standard constructor accepting an account id.

Signature
public Step2(Id accountId)
Parameters
Name Type Description
accountId Id Id the account id to process.

Methods

execute()

This is the main execute method required by the QueueableProcess abstract class. This is where developers will place the code they want to execute asynchronously in this step. In this case, all it does update the account phone field when the data Passthrough isn't null.

Signature
public override void execute()
Return Type

void