RE_Order.DoWork Interface

The RE_Order.DoWork Apex interface provides the capability to perform additional work after an order and the related records are committed to the database.

The transaction gets rolled back if there are any errors reported during the doWork execution.

Namespace

cgcloud

Example Implementation

cgcloud.RE_Order.DoWork;

Supported Methods

doWork()

Append the work to be executed after the order and its related records are committed to the database.

API Version: 59.0

Signature: global void doWork()

Example

global class RetailOrderSaveCustomization implements System.Callable {
  public class MyAfterCommitWork implements cgcloud.RE_Order.DoWork {
    cgcloud__Order__c m_order = null;

    MyAfterCommitWork(cgcloud__Order__c order) {
      m_order = order;
    }

    // This method will be called after the order and related record
    // changes are committed to the database.
    // If any error is thrown during the execution of doWork, the transaction
    // will be rolled back
    global override void doWork() {
      system.debug('Im here!');
    }
  }

  public Object call(String m, Map<String, Object> params) {
    cgcloud.RE_Order orderWrapper = (cgcloud.RE_Order) params.get('order');
    cgcloud__Order__c order = (cgcloud__Order__c) orderWrapper.getOrder()
      .getRecord();

    orderWrapper.registerWork(new MyAfterCommitWork(order));
    return null;
  }
}