• Muni.sfdc
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
I need to get the Accounts where there is no task is created in last 15 business days.I need to show those accounts on list view.

 
I have  two objects.Student and course.
There is a master-detail relationship between those objects.
i have to create one Visual force page with one search box called course and a button.whenever i enter the course name it has to display the students related to that course
I have 100,000 records.In that records ,few of them are duplicated.how can i delete that records.
can any one provide ideas and sample code 

Thanks
I have two objects
Student & Feedback
I have written a trigger on Feedback for send the feedback.So I have 2 fields(Email_id__c is a lookup filed,Subject_c)  on Feedback.when i click on save button ,the mail should sent to particular email that we selected  lookup field. 

Am Getting error"Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger sendmail caused an unexpected exception, contact your administrator: sendmail: execution of BeforeInsert caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Invalid to address : a029000000NcUIHAA3: []: Trigger.sendmail: line 23, column 1"
trigger sendmail on Feedback__c (before insert) { 
    
list<Messaging.SingleEmailMessage> email = new List<Messaging.SingleEmailMessage>(); 
for(Feedback__C femail:trigger.new)
{
    Messaging.SingleEmailMessage mail=new Messaging.singleEmailMessage();
list<string> sendTo=new List<string>();
sendTo.add(femail.Email_id__c);
mail.setToAddresses(sendTo); 
mail.setReplyTo('muneendar.sforce@gmail.com');
mail.setSenderDisplayName('wel come to Etchno');
mail.setSubject('Registation Success');
String Body='The spirit of Techno Schools is to make every child competitive and a complete person by our integrated programs for Pre-Primary, Primary and High school. It helps in understanding and implementing the core essentials of life through :';
Body+='Morals : The ability to discriminate right and wrong';
Body+='Values : The unique beliefs and feelings of an individual';
Body+='Ethics : The principles of behavior';
Body+='Problem Solving Techniques : The skill of resolving difficulties';
Body+='Positive Attitude : The highest form of healthy personality';
mail.setHtmlBody(Body);
email.add(mail);
    
}
    Messaging.SendEmail(email);
    }
Hi
    I am using after update on task , when ever i create new activity i should fire the trigger after update , my test class run but it cover only 44% couldnt find the reason for that. could you please help me

trigger Trigtask on Task(after update) 
{
Set<String> accids = new Set<String>();


    Set<String> taskaccid= new Set<String>();
       Set<String> acountph= new Set<String>();
           string taskacno ;
    
       for(task acc: Trigger.new) 
    {
         List<Task> accListS = [select accountid from task where accountid  IN :accids  AND CallDisposition LIKE '%Lead%'];
            if(accListS != null && !accListS .isEmpty()) 
            {
                taskacno = acc.whatid;
             taskaccid.add(acc.whatid);
           }
           }

      List<Account> accphone = [Select Id,IsPersonAccount,StrPhr_Do_Not_Call_Group_Practice__c, PersonDoNotCall,StrPhr_Lead_Qualified__c  from Account where Phone IN: taskaccid];       
      if(accphone != null && !accphone .isEmpty()) 
            {
             for(Account accph: accphone ) 
{
                              acountph.add(accph.Phone);
           }
    }
   
    if(!acountph.isEmpty()) 
    {
        List<Account> accList = [Select Id,IsPersonAccount,StrPhr_Do_Not_Call_Group_Practice__c, PersonDoNotCall,StrPhr_Lead_Qualified__c  from Account where Phone IN: acountph];        {
            for(Account acc: accList) 
            {
               if ( acc.IsPersonAccount == true && acc.StrPhr_Do_Not_Call_Group_Practice__c == False && acc.ID ==taskacno )  
            
                {
                acc.StrPhr_Do_Not_Call_Group_Practice__c=True;
                 //acc.PersonDoNotCall = True;

                                   }
                if ( acc.IsPersonAccount == true && acc.StrPhr_Do_Not_Call_Group_Practice__c == False && acc.ID !=taskacno ) 
                {
                acc.StrPhr_Do_Not_Call_Group_Practice__c=True;
                 acc.PersonDoNotCall = True;

                                   }

                                   
                         }
            update accList;
        }
    }
}

test code

@isTest 
public class Tritasktest{

    static testMethod void testMethodOne() 
    {
       
          Account accone = new Account();
        accone .Name='Test Account Two';
        accone .Phone='555555';
        accone .StrPhr_Do_Not_Call_Group_Practice__c = false;
        insert accone ;
        accone .Phone='555555';
                accone .StrPhr_Do_Not_Call_Group_Practice__c = true;
        update accone ;

        Task taskone= new task();
         taskone.whatid= accone .id;
         taskone.CallDisposition ='Leadrep';
                                    insert taskone;
        Account acctwo = new Account();
        accTwo.Name='Test Account Two';
        acctwo.Phone='555555';
        accTwo.StrPhr_Do_Not_Call_Group_Practice__c = false;
        insert accTwo;
        acctwo.Phone='555555';
                accTwo.StrPhr_Do_Not_Call_Group_Practice__c = true;
        update accTwo;

         Task tasktwo= new task();
         tasktwo.whatid= acctwo .id;
         tasktwo.CallDisposition ='Leadrep';
         insert tasktwo;   
         tasktwo.whatid= acctwo.id;
         Task t=[SELECT whatid,CallDisposition FROM Task WHERE whatid=:acctwo.id].get(0);

         tasktwo.CallDisposition='Lead';
          update tasktwo;     
          
              Account acc1 = [select Id,isPersonAccount, StrPhr_Do_Not_Call_Group_Practice__c,phone from Account where Id =: accTwo.Id LIMIT 1];
        System.assertEquals(true, acc1.StrPhr_Do_Not_Call_Group_Practice__c);  
        System.assertEquals('555555', acc1.Phone);  
        
    task acc = [select Id,whatid,accountid, CallDisposition,Account_Ph_No__c from task where whatId =: accone.Id LIMIT 1];
  
      
        System.assertEquals(acc.whatid,accone.id );
         
        



    }
    static testMethod void testMethodTwo() 
    {
        Account accOne = new Account();
        accOne.Name='Test Account One';
        accOne.StrPhr_Do_Not_Call_Group_Practice__c = false;
        accOne.Phone ='5555555555';
        insert accOne;
         

        Account accTwo = new Account();
        accTwo.Name='Test Account Two';
        accTwo.StrPhr_Lead_Qualified__c = false;
        accTwo.Phone ='5555555555';
        accTwo.StrPhr_Do_Not_Call_Group_Practice__c = false;
        accTwo.PersonDoNotCall = false;


        insert accTwo;

        accTwo.StrPhr_Lead_Qualified__c = True;
         accTwo.Phone ='5555555555';
         accTwo.StrPhr_Do_Not_Call_Group_Practice__c = True;
        
          

        update accTwo;

    }



}
I need to get the Accounts where there is no task is created in last 15 business days.I need to show those accounts on list view.