• learning_SFDC
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
Hi guys,

I have a object with records:
Name        form_no         createddate
test1         2222              23/03/2015
test1         2222              24/03/2015

test2         3333              23/03/2014
test2         3333              24/03/2014

test3          4444             22/03/2014

In my report i want to display latest created record  and should elminate the other records from report
like this:-
test1         2222              24/03/2015
test2         3333              24/03/2014
test3          4444             22/03/2014

Can please any one help me to achieve this with standard report

Thanks

            
hi 

I have written test class for batch apex and schedule class my schedule class is 100 but batch only 18 please help me in code coverage:-

Batch class:-
 
global class Del_Email implements Database.Batchable<sobject> ,Database.Stateful
{
   global String query;
   global String email_hdr;
   global String email_reslts;
   global integer email_count;  
   global boolean send_email;
   global date ext_date=System.today().addDays(-14);  
  
  public Del_Email(string q)
  {
    this.query=q;
    email_hdr='Id,Name,Subject Line\n';
    email_reslts=email_hdr;
    email_count=0;
    send_email=false;   
    
  }
   global Database.QueryLocator start(Database.BatchableContext BC){
      system.debug(query);
      return Database.getQueryLocator(query);
   }
   
   global void execute(Database.BatchableContext BC,List<sobject> recs)
   {
    
        string temp;
        List<xtma_Individual_Email_Result__c> delIer=new List<xtma_Individual_Email_Result__c>();
        for(sobject s:recs)
        {
            xtma_Individual_Email_Result__c Ier=(xtma_Individual_Email_Result__c)s;         
            string name =Ier.Name==null?'':string.ValueOf(Ier.Name).replaceAll(',','');
            
            
            if(temp==null)temp=' ';         
            temp+=Ier.id+','+name+','+sub+'\n';
            delier.add(ier);        
        }
        if(temp!=null)
        {
            try{
                Delete delier;
                email_reslts+=temp;
                send_email=true;                
            }   
            catch(Exception e)
            {
                system.debug(e);
            }   
            if(Blob.valueOf(email_reslts).size()>=8388608)
            {
                sendmail(email_reslts,email_count);
                email_reslts=email_hdr;
                send_email=false;
            }
        }
    
   }  
   
   global void finish(Database.BatchableContext BC){        
        System.debug(LoggingLevel.WARN,'Deleting Individual Email Results Finished');
        if(send_email && email_reslts!=email_hdr)
        {
            sendmail(email_reslts,email_count);
        }
   }
   
   public void sendmail(string mailbody,integer mailcount)
   {
            Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
            efa.setFileName('Email Results'+System.today().day()+'_'+System.today().Month()+'_'+System.today().Year()+'_'+mailcount+'.csv');
            Blob b=Blob.valueOf(mailbody);
            efa.setContentType('text/csv');             
            efa.setBody(b);       
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); 
            mail.setToAddresses(new String[] {'test@gmail.com'});        
            mail.setSenderDisplayName('Batch Processing');
            mail.setSubject('Batch Process Completed - '+system.today());
            mail.setPlainTextBody('Please find the attachment of deleted records, dated : '+system.today());            
            mail.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});     
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
            email_count++;  
   }
   
}




Execute and mail method is not covering in test class


Schedule class:-
global class bulk_delete_emails Implements Schedulable{

public static String CRON_EXP = '0 0 0 3 9 ? 2022';
/*Method to query for the records to delete */

     global void Execute(SchedulableContext SC){             
        string query='select id,name,Subject_Line__c from xtma_Individual_Email_Result__c where Date_Time_Sent__c<=:ext_date limit 20 ';            
        Del_Email der=new Del_Email(query);        
        database.executebatch(der);         
     }     
}


Test Class:-
@IsTest
private class bulk_delete_individual_emails_Test{
 static testmethod void bulk_delete_individual_emails() {   
   
    date ext_date=System.today().addDays(-14);  
    set<id>ids=new set<id>(); 
    

     List <xtma_Individual_Email_Result__c> lds = new List<xtma_Individual_Email_Result__c>();
            for(integer i = 0; i<5; i++){
             
                xtma_Individual_Email_Result__c l = new xtma_Individual_Email_Result__c(); 
                l.name='anil';
                l.Date_Time_Sent__c=system.today();
                l.Date_Bounced__c=system.today();
                l.Date_Unsubscribed__c=system.today();
                l.Date_Time_Opened__c=system.today();               
                lds.add(l);
                
            }    
        insert lds;       
       
       Test.startTest(); 
       string query='select id,name,Subject_Line__c from xtma_Individual_Email_Result__c where Date_Time_Sent__c<=:ext_date   limit 200 ';
       Del_Email c = new Del_Email (query);
       Database.executeBatch(c);
 Test.stopTest();

  

   }
   }


 
Hi Members,

Did any one used Jeffdouglas code to overide standard quick create Popup Dialog :- http://blog.jeffdouglas.com/2011/08/12/roll-your-own-salesforce-lookup-popup-window/ 
If yes can any body tell me how to get account id in save method to contact record.

Thanks in Advance
Hi guys,

I have a object with records:
Name        form_no         createddate
test1         2222              23/03/2015
test1         2222              24/03/2015

test2         3333              23/03/2014
test2         3333              24/03/2014

test3          4444             22/03/2014

In my report i want to display latest created record  and should elminate the other records from report
like this:-
test1         2222              24/03/2015
test2         3333              24/03/2014
test3          4444             22/03/2014

Can please any one help me to achieve this with standard report

Thanks

            
Hi guys,

I have a object with records:
Name        form_no         createddate
test1         2222              23/03/2015
test1         2222              24/03/2015

test2         3333              23/03/2014
test2         3333              24/03/2014

test3          4444             22/03/2014

In my report i want to display latest created record  and should elminate the other records from report
like this:-
test1         2222              24/03/2015
test2         3333              24/03/2014
test3          4444             22/03/2014

Can please any one help me to achieve this with standard report

Thanks