• dkgm
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

Hi,

 

 I want to write a validation rule on  lead conversion.The condition will be like this:-

   i. Lead status is a picklist value.If lead status is  'NDA Signed' then it will convert the lead.If lead status is except the NDA Signed and I will click the convert button it will display an error meassage like 'lead conversion not possible'.

  • September 30, 2013
  • Like
  • 0

This is the schedule class for which i need to write test class:

 

global class SendNotificationToOpportunityOwner Implements Schedulable{
   List<String> oppIdList=new List<String>();
   List<OpportunityLineItem> productList;
   global void execute(SchedulableContext sc){
       System.debug('*******************');
       productList=[SELECT SHRMI_End_Date__c,Id,OpportunityId FROM OpportunityLineItem WHERE SHRMI_End_Date__c != null AND OpportunityId != null ] ;
       for(OpportunityLineItem oppLineItem :productList){
          Integer numberDaysRemaining =System.Today().daysBetween(oppLineItem.SHRMI_End_Date__c);
          if(numberDaysRemaining ==60){
              oppIdList.add(oppLineItem.OpportunityId);
          }//end of If
      }//end of for loop 
      List<Opportunity> oppList=[SELECT Id,OwnerId,SHRMI_OwnerName__c,SHRMI_OwnerEmail__c from Opportunity WHERE Id IN:oppIdList];
      List<Messaging.SingleEmailMessage> emailList = new List<Messaging.SingleEmailMessage>();
      List<Task> taskListtoInsert=new List<Task>();
      for(Opportunity opp :oppList ){
       String oppUrl = URL.getSalesforceBaseUrl().toExternalForm() +'/' + opp.id;
       //creating new task under opportunity
       Task tsk=new Task();
          tsk.whatid=opp.Id;
          tsk.OwnerId=opp.OwnerId;
          tsk.Priority='High';
          tsk.Subject='Follow up on renewal membership';
          tsk.status='Not Started';
          tsk.ActivityDate=System.Today().addDays(60);
          taskListtoInsert.add(tsk);
       //Sending email to opportunity owner
       Messaging.SingleEmailMessage mail= new Messaging.SingleEmailMessage();
           String[] toAddresses = new String[]{opp.SHRMI_OwnerEmail__c};
           mail.setToAddresses(toAddresses);
           mail.setSubject('Licence Renewal');
           mail.setHtmlBody('Dear  '+opp.SHRMI_OwnerName__c+',<br/><br/>Please follow up with the  customer to renew the license.'+'<br/><br/><br/>'+'For details, click the link below'+'<br/>'+oppUrl+'<br/><br/>'+'Thanks,'+'<br/>'+'<b>'+'System Admin'+'</b>');
           emailList.add(mail);
      }
      try{
          Insert taskListtoInsert;
      }catch(DmlException de){System.debug(de);}
      Messaging.sendEmail(emailList);
    }//end of method
}//end of class

 

This is my test class which is covering 38% test coverage.How will i increase my test coverage???

 

 

@isTest
private class TestSendNotificationToOpportunityOwner {

static testMethod void myUnitTest() {
Test.startTest();
String testCronExp = '0 0 1-23 * * ?';
SendNotificationToOpportunityOwner enqObj = new SendNotificationToOpportunityOwner();
System.schedule('RandomizationSchedule', testCronExp, enqObj);
Test.stopTest();
}
}

 

 

 

  • September 24, 2013
  • Like
  • 0

This is the schedule class for which i need to write test class:

 

global class SendNotificationToOpportunityOwner Implements Schedulable{
   List<String> oppIdList=new List<String>();
   List<OpportunityLineItem> productList;
   global void execute(SchedulableContext sc){
       System.debug('*******************');
       productList=[SELECT SHRMI_End_Date__c,Id,OpportunityId FROM OpportunityLineItem WHERE SHRMI_End_Date__c != null AND OpportunityId != null ] ;
       for(OpportunityLineItem oppLineItem :productList){
          Integer numberDaysRemaining =System.Today().daysBetween(oppLineItem.SHRMI_End_Date__c);
          if(numberDaysRemaining ==60){
              oppIdList.add(oppLineItem.OpportunityId);
          }//end of If
      }//end of for loop 
      List<Opportunity> oppList=[SELECT Id,OwnerId,SHRMI_OwnerName__c,SHRMI_OwnerEmail__c from Opportunity WHERE Id IN:oppIdList];
      List<Messaging.SingleEmailMessage> emailList = new List<Messaging.SingleEmailMessage>();
      List<Task> taskListtoInsert=new List<Task>();
      for(Opportunity opp :oppList ){
       String oppUrl = URL.getSalesforceBaseUrl().toExternalForm() +'/' + opp.id;
       //creating new task under opportunity
       Task tsk=new Task();
          tsk.whatid=opp.Id;
          tsk.OwnerId=opp.OwnerId;
          tsk.Priority='High';
          tsk.Subject='Follow up on renewal membership';
          tsk.status='Not Started';
          tsk.ActivityDate=System.Today().addDays(60);
          taskListtoInsert.add(tsk);
       //Sending email to opportunity owner
       Messaging.SingleEmailMessage mail= new Messaging.SingleEmailMessage();
           String[] toAddresses = new String[]{opp.SHRMI_OwnerEmail__c};
           mail.setToAddresses(toAddresses);
           mail.setSubject('Licence Renewal');
           mail.setHtmlBody('Dear  '+opp.SHRMI_OwnerName__c+',<br/><br/>Please follow up with the  customer to renew the license.'+'<br/><br/><br/>'+'For details, click the link below'+'<br/>'+oppUrl+'<br/><br/>'+'Thanks,'+'<br/>'+'<b>'+'System Admin'+'</b>');
           emailList.add(mail);
      }
      try{
          Insert taskListtoInsert;
      }catch(DmlException de){System.debug(de);}
      Messaging.sendEmail(emailList);
    }//end of method
}//end of class

 

This is my test class which is covering 38% test coverage.How will i increase my test coverage???

 

 

@isTest
private class TestSendNotificationToOpportunityOwner {

static testMethod void myUnitTest() {
Test.startTest();
String testCronExp = '0 0 1-23 * * ?';
SendNotificationToOpportunityOwner enqObj = new SendNotificationToOpportunityOwner();
System.schedule('RandomizationSchedule', testCronExp, enqObj);
Test.stopTest();
}
}

 

 

 

  • September 24, 2013
  • Like
  • 0

This is my first APEX coding... and, I need a bit of help. 

 

I am trying to count the # of related records...

 

I'd then, like to make a field on the current record equal to this count.

 

The following seems to work well... except I don't know how to limit the select statement to where the related_id = the id of the current record.  How do I make the variable "sid" = the id on the current record on the object Students?  Also, do I need a "loop" -- if so, how would this look?

 

Many thanks!

 

trigger CountRelatedCallLogs on Student__c (before insert, before update) { Student__c[] s = Trigger.new; String sid = null; Sid = s.id; LIST <Student_Call_Log__c> log = [SELECT Id, Related_Student__c, Date__c, Note__c FROM Student_Call_Log__c clog WHERE Student_Call_Log__c.Related_Student__c = :sid ORDER BY Related_Student__c, Id DESC LIMIT 1000]; s[0].Call_Count__c = log.size (); s[0].Most_Recent_Call_Note__c = sid(); }

 

 

  • January 19, 2010
  • Like
  • 0