Giter VIP home page Giter VIP logo

force-brf's People

Contributors

afawcett avatar garychenming avatar mandar19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

force-brf's Issues

Issue with history and casecomment batches

The execute method in the class brf_BatchableRetryJob will throw an exception when the batch operates on history sobjects i.e. accounthistory, claimhistory. CaseComment has the same issue

A sobject instance cannot be created for those types with the following call:
//errorId points to either claimhistory, casecomment etc
sObjectType.newSObject(errorId);

https://help.salesforce.com/s/articleView?id=000332227&type=1

I'm "solving" this with a switch case. However I'm not satisfied with this solution since I'll need to rewrite the brf_BatchableRetryJob.execute method each time a new batch is introduced that operates on the history objects/casecommments etc...

public void execute(Database.BatchableContext ctx, List<brf_BatchableError> scope) {
    // One batch scope here represents an entire previously failed batch scope
    brf_BatchableError error = scope[0];

    // Construct an SObject scope to pass to the execute method
    // TODO: Support non-SObject scopes
    List<Id> scopeErrorIds = error.JobScope.split(',');
    SObjectType sObjectType = scopeErrorIds[0].getSobjectType();
    List<SObject> retryScope = new List<SObject>();
    for (Id errorId : scopeErrorIds) {
        SObject sObj = null;
        switch on error.ApexClassName {
            when 'BatchAccountHistory', 'BatchAccountHistory_2' {
                sObj = Schema.getGlobalDescribe().get('AccountHistory').newSObject();
                sObj.Id = errorId;
            }
            when 'ClaimHistory' {
                sObj = Schema.getGlobalDescribe().get('ClaimHistory').newSObject();
                sObj.Id = errorId;
            }
            when else {
                sObj = sObjectType.newSObject(errorId);
            }
        }

        if (sObj != null) {
            retryScope.add(sObj);
        }
    }

    // Invoke the execute method on the original batch apex job class
    Type apexJobClassType = Type.forName(error.ApexClassName);
    Database.Batchable<SObject> batchJob = (Database.Batchable<SObject>) apexJobClassType.newInstance();
    batchJob.execute(ctx, retryScope);
}

An better solution for this issue would probably to extend the brf_BatchableErrorHandler interface with a method that returns the sobject type i.e. 'ClaimHistory' or 'Account' etc.. => then utilize that in the execute method

Typo in README file

Deploy Setup

sfdc force:source:push // replace sfdc with sfdx
sfdx force:user:permset:assign --permsetname Billing
sfdx force:user:permset:assign --permsetname brf_BatchRetryFramework

Data Setup

sfdc force:apex:execute // replace sfdc with sfdx

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.