Activity Forums Salesforce® Discussions I have added an string 'my name' to all users in Account object through batch apex,now how to remove that 'my name'?

  • Saurabh

    Member
    April 25, 2017 at 1:55 pm

    Hi Suraj

    You can use this code given below:

    global class classname implements Database.Batchable<sObject>{
    global Database.QueryLocator start(Database.BatchableContext batchcontext){
    String query = 'select id,name from Account';
    return Database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext batchcontext,list<Account> scope){
    for(Account a:scope){
    a.name = a.name.removeEnd('stringname');// If you appended string at last

    a.name = a.name.removeStart('stringname');//If you appended String at start
    update scope;
    System.debug(scope);

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

    Hope it may help

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

Salesforce Admin Certification 2020 Questions Explained with References - Part II

Video in

How to prepare and pass Salesforce Admin Certification with Practice Exam Questions 2020 practice questions and answers for the Salesforce Administration Salesforce Certified Admin Exam Questions Salesforce Administrator Certification Exam…