GithubHelp home page GithubHelp logo

niv-shah / force-brf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from afawcett/force-brf

0.0 0.0 0.0 41 KB

Work in progress reference lib for BatchApexErrorEvent handling

License: BSD 3-Clause "New" or "Revised" License

Apex 85.88% JavaScript 14.12%

force-brf's Introduction

force-brf - Batch Retry Framework

Reference lib for BatchApexErrorEvent handling. See blog here for more details.

In Winter’19 the BatchApexErrorEvent standard platform event was introduced. This event extends the above error reporting facilities with the ability to use Platform Events to listen (subscribe) to all job failures in variety of ways using clicks or code (clicks are not supported in Beta). The fields on the event give rich access to the exception type, stack trace, affected scope (records) and job ID. You can review a full list of the available fields here.

BatchApexErrorEvent. An event record provides more granular error tracking than the Apex Jobs UI. It includes the record IDs being processed, exception type, exception message, and stack trace. You can also incorporate custom handling and retry logic for failures. You can invoke custom Apex logic from any trigger on this type of event, so Apex developers can build functionality like custom logging or automated retry handling.

image

Deploy Setup

Run the following commands to deploy:-

sfdx force:source:push
sfdx force:user:permset:assign --permsetname Billing
sfdx force:user:permset:assign --permsetname brf_BatchRetryFramework

Data Setup

sfdx force:apex:execute

Run the following Apex code block to configure test data.

delete [select Id from Invoice__c];
delete [select Id from Order];
delete [select Id from Account];
delete [select Id from brf_BatchApexErrorLog__c];
Account orderAccount = new Account();
orderAccount.Name = 'Great customer!';
insert orderAccount;
List<Order> orders = new List<Order>();
for(Integer orderIdx = 0; orderIdx < 1000; orderIdx++) {
    Order order = new Order();
    order.Name = 'Ref:'+orderIdx;
    order.Status = 'Draft';
    order.EffectiveDate = System.today();
    order.AccountId = orderAccount.Id;
    orders.add(order);
}
insert orders;

Demo Steps

Perform the following steps to try out the framework with the sample app (included):-

  1. Open the Billing app
  2. Click the Orders tab and select the All list view
  3. Click the Invoice Generation button to start the job
  4. Open the Failed Jobs utlity bar and click Refresh button to see logged failures
  5. Use the Orders tab and Bad Orders list view to review bad records and delete one or edit Order Start Date to another date
  6. Open the Failed Jobs utility bar and click Retry action on the failed job
  7. Click the Refresh button to review remaining errors, repeat steps 5-7 until all clear!

force-brf's People

Contributors

afawcett avatar garychenming avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.