Activity Forums Salesforce® Discussions How to create records of any selected object using Salesforce Batch Apex Class?

  • Rajan

    Member
    July 30, 2019 at 10:55 am

    Hi Namrata

    global class batchForUserInput implements Database.Batchable<sObject> {
    global batchForUserInput(string inputUser){
    this.inputUser = inputUser;
    }
    global Database.QueryLocator start(Database.BatchableContext BC) {
    String query = 'SELECT Id,Name FROM inputUser';
    return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<sObject> scope) {
    for(sObject a : scope)
    {
    a.Name = a.Name + 'Updated';
    }
    update scope;
    }

    global void finish(Database.BatchableContext BC) {
    }
    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos