• penchala raju
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 84
    Questions
  • 9
    Replies
global class batchupdate implements Database.Batchable<sobject>
{
   // list<account> s{set;get;}
    global Database.QueryLocator start(Database.BatchableContext bc)
    {
        String Query =  'select id,Transaction_type__c,amount_info__c from Transaction__c';
        System.debug('------Query---->'+Query);
        return Database.getQueryLocator(Query);
    }
    global void execute(Database.BatchableContext bc,list<Transaction__c> scope)
    {
     // s=new list<account>();
        list<Transaction__c> cust=new List<Transaction__c>();
        System.debug('------scope---->'+scope.size());
       // scope=s;
        for(Transaction__c c:scope)
        {
            c.amount_info__c=5656;
            cust.add(c);
           //  system.debug(cust);
        }

        update cust;
       
    }
    global void finish(Database.BatchableContext bc)
{
    Messaging.SingleEmailMessage mail1=new Messaging.SingleEmailMessage();
            String[] toadd=new String[]{'praju.salesforce@gmail.com'};
           mail1.setToAddresses(toadd);
            mail1.setSubject('Test mail');
            mail1.setPlainTextBody('this is a test mail');
                        Messaging.SingleEmailMessage mail2=new Messaging.SingleEmailMessage();
            mail1.setToAddresses(toadd);
            mail1.setSubject('Test mail');
            mail1.setPlainTextBody(list<Transaction__c> cust);
            Messaging.sendEmail(new Messaging.singleEmailMessage[]{mail1});
    }

     
}
global class batchupdate implements Database.Batchable<sobject>
{
   // list<account> s{set;get;}
    global Database.QueryLocator start(Database.BatchableContext bc)
    {
        String Query =  'select id,Transaction_type__c,amount_info__c from Transaction__c';
        System.debug('------Query---->'+Query);
        return Database.getQueryLocator(Query);
    }
    global void execute(Database.BatchableContext bc,list<Transaction__c> scope)
    {
     // s=new list<account>();
        list<Transaction__c> cust=new List<Transaction__c>();
        System.debug('------scope---->'+scope.size());
       // scope=s;
        for(Transaction__c c:scope)
        {
            c.amount_info__c=5656;
            cust.add(c);
           //  system.debug(cust);
        }

        update cust;
       
    }
    global void finish(Database.BatchableContext bc)
{
    Messaging.SingleEmailMessage mail1=new Messaging.SingleEmailMessage();
            String[] toadd=new String[]{'praju.salesforce@gmail.com'};
           mail1.setToAddresses(toadd);
            mail1.setSubject('Test mail');
            mail1.setPlainTextBody('this is a test mail');
                        Messaging.SingleEmailMessage mail2=new Messaging.SingleEmailMessage();
            mail1.setToAddresses(toadd);
            mail1.setSubject('Test mail');
            mail1.setPlainTextBody(list<Transaction__c> cust);
            Messaging.sendEmail(new Messaging.singleEmailMessage[]{mail1});
    }

     
}
global class batchupdate implements Database.Batchable<sobject>
{

    global Database.QueryLocator start(Database.BatchableContext bc)
    {
        return Database.getQueryLocator('select id,name,industry from account');
    }
    global void execute(Database.BatchableContext bc,list<account> scope)
    {
        list<account> cust=new List<account>();
        for(account c:scope)
        {
            c.name='mr'+c.name;
            cust.add(c);
        
        }
        update cust;
    }
        global void finish(Database.BatchableContext bc)
        {
           
            
        }
    
}

batch execution:

batchupdate bp=new batchupdate();
Database.executeBatch(bp,5);

here i divided 5 batches.i want to display these records in visual force

i got an error like "Method does not exist or incorrect signature: [Schema.ChildRelationship].getChildObject()"" in 14th line of the program


public class SchemaFieldExample {
list<selectoption> options;
  public list<selectoption>getoptions()
    {
        return options;
    }
    public SchemaFieldExample()
    {
        options=new list<selectoption>();
        schema.DescribeSObjectResult r=Account.SobjectType.getDescribe();
        list<schema.ChildRelationship> c=r.getChildRelationships();
        for(schema.ChildRelationship x:c)
        {
            String name=''+x.getChildObject();
            selectoption op=new selectoption(name,name);
            options.add(op);
        }
    }
    
}
global class customerbatch implements Database.Batchable<sobject>
{
    public String myname;
    global customerbatch(String myname)
    {
        this.myname=myname;
    }
    global Database.QueryLocator start(Database.BatchableContext bc)
    {
        return Database.getQueryLocator('select id,AType__c from Customer__C where name='+myname);
    }
    global void execute(Database.BatchableContext bc,list<customer__c> scope)
    {
        list<Customer__c> cust=new List<Customer__c>();
        for(Customer__c c:cust)
        {
            c.AType__c='saving';
            cust.add(c);
        
        }
        update cust;
    }
        global void finish(Database.BatchableContext bc)
        {
            Messaging.singleEmailMessage myemail=new Messaging.singleEmailMessage();
            String[] toadd=new String[]{'penchalaraju7@gmail.com'};
            myemail.setToAddresses(toadd);
            myemail.setSubject('my notification');
            messaging.sendEmail(new messaging.Email[]{myemail});
            
        }
    
}