• Navneeth
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 25
    Questions
  • 8
    Replies
Hi,

   I have developed an apex class which displays the TargetDate of CaseMilestone related with a particular case.
   
The following is my Apex class:-

public class Clock {
Public String  casename {get;set;}
    public String getCaseMilestone() {
        return null;
    }


    public Clock() {
    }


List<CaseMilestone> sr = new List<CaseMilestone>();
List<CaseMilestone> srresponse = new List<CaseMilestone>();
ID myId;
public Datetime targetDate{get;set;}
public Datetime targetResponseDate{get;set;}

public Clock(ApexPages.StandardController controller) {
   myId = ApexPages.CurrentPage().getParameters().get('id');
  
   sr = [select TargetDate from CaseMilestone where CaseId =: myId and MilestoneTypeId ='557900000008Orj'];
srresponse = [Select TargetDate from CaseMilestone where CaseId =: myId and MilestoneTypeId ='557900000008OrU'];
  
   for(CaseMilestone s1 : sr)
   {
       targetDate  = s1.TargetDate;
    
   }
  
   for(CaseMilestone s2 : srresponse)
   {
       targetResponseDate  = s2.TargetDate;
      
   }
    }
}
    
  Now i need to write a test class for this class.  I have written a test class but it is not working. 

 The following is my test class

@isTest
private class CaseTest{
static testmethod void testLoadData(){
String caseJSON = '{"attributes":{"type":"CaseMilestone","url":"/services/data/v25.0/sobjects/CaseMilestone/55590000000CiTX"},"Id":"55590000000CiTX","MilestoneTypeId":"557900000008OrU","TargetDate":"5/30/2014 6:01 PM"}';
CaseMilestone c = (CaseMilestone) JSON.deserialize(caseJSON, CaseMilestone.class );
System.debug('Test case:' + c.TargetDate);
System.debug('Test caseId:' + c.Id);
System.debug('Test caseStatus:' + c.MilestoneTypeId);

CaseMilestone c1 = new CaseMilestone();
c1.Id = c.Id;
//c1.MilestoneTypeId = c.MilestoneTypeId;
//c1.TargetDate= c.TargetDate;
update c1;

//System.debug('Test caseStatus1:' + c1.status);
System.assertequals(c1.TargetDate,c.TargetDate);
}
}

This class saves but it doesnt cover anything [0% Code coverage].

I  have commented two lines of code in my above test class. This is because if i remove those comments then i get an compile error which states the "Field: CaseMilestone.MileStonetypeId is not a Writable Field". Same is the error with TargetDate field. It shows the error "Field: CaseMilestone.TargetDate is not a Writable Field". 

Pls help me tweak the code properly so that i get atleast Some code coverage. Why is this test class not covering any code. Why am i getting the Field not Writable error when i remove the comments.

If possible pls help me with the new code. Its really urgent. I need to Migrate data from one instance to another and i am lagging because of this. 

Awaiting for reply. Thanks a ton.
Hi,

i need to write test class for the below mentioned class. This class sends Email to contacts of Accounts whose installed product is due for maintainence in the near future.

Pls help me write test class for this.


global class SendMail {
public List<Preventive_Maintenance_Coverage__c> installprods;
List<String> lcontactEmails = new List<String>();
List<Contact> con = new List<Contact>();
Set<ID> listofIDsToProcess = new Set<ID>();
public Date t = System.today();
public Date criteria;



        public SendMail(){
                           installprods = this.Findinstallprods();
                          // installprods.clear();
                         }
  
   

public List<Preventive_Maintenance_Coverage__c> Findinstallprods() {
   // query to find only the cases that match your conditions requiring email alerts to be sent


   installprods = [select id, Installed_Product__r.Name,Installed_Product__r.Date_Installed__c,frequency__c from Preventive_Maintenance_Coverage__c];

    for(Preventive_Maintenance_Coverage__c p : installprods)
            {
                Integer frequencyval = Integer.valueOf(String.valueOf(Math.roundToLong(P.frequency__c )));
                if(p.Installed_Product__r.Date_Installed__c + frequencyval - 5 == t)
                    {
                         listofIDsToProcess.add(p.Id);
                          system.debug('ID TO PROCESS' + listofIDsToProcess);
                    }
            }
   return installprods;
}
    
   List<Account> accList  = [SELECT id,(SELECT Email FROM Contacts) FROM Account WHERE id IN (SELECT Account__c FROM Installed_Product__c WHERE Id IN: listofIDsToProcess)];
   {
            if(accList.size() > 0) {
        for(Contact con : accList[0].contacts){
          
           if(!String.isBlank(con.Email)){
               lcontactEmails.add(con.Email);
            }
        }
        }
        if(!lcontactEmails.isEmpty()){
            sendEmail(lcontactEmails); 
        }
    }

public static void sendEmail (List<String> toAddress){
    
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        //set the email properties
        mail.setToAddresses(toAddress);
        mail.setSenderDisplayName('SF.com Email Agent');
        mail.setSubject('A new reminder');
        mail.setHtmlBody('Service Maintaince Reminder .');
    
        //send the email
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail } );
      }

}
Hi,

 i need to write test class for the below mentioned class. This class displays the case milestone resolution target time. 
Pls help me write test class for this. 


Class code:- 

public class Clock {
Public String  casename {get;set;}
    public String getCaseMilestone() {
        return null;
    }


    public Clock() {

    }


List<CaseMilestone> sr = new List<CaseMilestone>();
List<CaseMilestone> srresponse = new List<CaseMilestone>();
ID myId;
public Datetime targetDate{get;set;}
public Datetime targetResponseDate{get;set;}

public Clock(ApexPages.StandardController controller) {
   myId = ApexPages.CurrentPage().getParameters().get('id');
  
   sr = [select TargetDate from CaseMilestone where CaseId =: myId and MilestoneTypeId ='557900000008Orj'];
srresponse = [Select TargetDate from CaseMilestone where CaseId =: myId and MilestoneTypeId ='557900000008OrU'];
  
   for(CaseMilestone s1 : sr)
   {
       targetDate  = s1.TargetDate;
    
   }
  
   for(CaseMilestone s2 : srresponse)
   {
       targetResponseDate  = s2.TargetDate;  
    }
  }
}
Hi, 

 I have a requirement where in i need to perform a auto entitlement check whenever a case is created.
What i want to do exactly is as belows:-

Whenever a case is created , i need to check whether the product in that case is already covered/supported by any exisiting entitlement or not. If it is supported then show the matching list and the automatically map it to the entitlement.  

To be more specific , i need to check that both the accounts and the product related with the case are covered under any service contract. if they are covered under any service contract then they will not be billed, and the billing type field value would change to "contract". Iif they are not covered under service contract then they will be billed.

Please help me the scenaro. I am stuck here as i dont know how to start the process itself. what  all should i need to do to achieve this. i mean should i right a rule or should i right a trigger or apex class? Help me move forward in the right direction with respect to the above scenario.   

P.s :- There is a software called Service Max which does this feature. Need to replicate the same in my org. 
HI,  

 I need to integrate and display a Digital Running Clock  in a visualforce page which displays the time from a date time field of an object. The input for the Digital clock should be date field from the object.

Help me achieve this. Any suggestions ideas accepted. if possible post a sample post/code. Thanks

Any idea how to do this? 
Hi,

I am trying to integrate SAP and salesforce using Informatica Cloud tool.  I have established connection to SAP successfully and am also able to see the Sap tables. But the problem is when i try to select any source object / table in SAP to fetch data i get an error which states exactly like  ""Field MODE is not a member of INPUT"". Any source object/table i select i get the same error. I am not able to understand what the error is ? Any help would be greatly appreciaited.  Thanks

Hi i m tryin to rescheduled already scheduled apex classes using system.schedule method.

 

When tryin to do this i m getting an error.

 

The following is my controller code

 

public with sharing class controller_dynamicScheduler {
    public String classNameToSchedule;
    public List<ApexClass> getschedulableClasses() {
        List<ApexClass> allClasses = [Select ApiVersion, Body, bodyCrc, IsValid, LengthWithoutComments, Name, NamespacePrefix, Status from ApexClass];
        List<ApexClass> schedulableClasses = new List<ApexClass>();
        for(ApexClass c : allClasses) {
            if(c.Body.containsIgnoreCase(ApexSchedulerSettings__c.getInstance('Scheduler').Schedule_Class_Keyword__c)) {
                schedulableClasses.add(c);
            }
        }
        return schedulableClasses;
    }
    
    public PageReference scheduleNow() {
        System.debug('Class Name '+classNameToSchedule);
        
        String jobName = classNameToSchedule+' - '+System.now().format();
        String schTime = System.now().addMinutes(1).format('ss mm HH dd MM ? yyyy');
        ApexClass class2Schedule = [Select Name from ApexClass Where Name=:classNameToSchedule];
         System.schedule(jobName, schTime, class2Schedule);
        return null;
    }
}

 The following is my apex page code:

 

<apex:page controller="controller_dynamicScheduler">
<apex:form >
    <apex:pageMessages />
    <apex:pageBlock mode="edit" title="Schedulable Classes">
        <apex:pageBlockTable value="{!schedulableClasses}" var="apexClass">
            <apex:column value="{!apexClass.Name}"/>
            <apex:column value="{!apexClass.ApiVersion}"/>
            <apex:column >
                <apex:commandLink value="Schedule Now">
                    <apex:param name="className" assignTo="{!classNameToSchedule}" value="{!apexClass.Name}"/>
                </apex:commandLink>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

 i m getting the following error msg

 

Error: controller_dynamicScheduler Compile Error: You must select an Apex class that implements the Schedulable interface. at line 21 column 2

 

Hi , 

 

I have a requirement where in i need to reschedule already scheduled apex classes. I have used System.Schedule method to achieve the same. Since System.Schedule only works with the class names(Need to give classname as a third parameter) and since that would become static , i tried using "Reflection concept of java" so that i can pass the instance of an object as a parameter and thus make it work for more than one class. (I have more than once class to schedule in my organisation). 

 

I get an error which states "Attempt to de-reference a null object"

 

The following is my Controller code. 

 

global with sharing class GetAllApexClasses {
    public PageReference shedulerClicked() {
        return null;
    }
public void scheduleClicked () {
        return ;
    }
    public String asyncapexjob { get; set; }
    public string className { get; set; }
    public String schedule  { get; set; }  
    public List<AsyncApexJob> apexclassList{get; set;}
    public List<ApexClass> classList{get;set;}
    public List<CronTrigger> CronList{get;set;}
    
    public GetAllApexClasses(){    
    apexclassList = new List<AsyncApexJob>();
    apexclassList = [SELECT ApexClassID, CompletedDate,Status,CreatedDate,TotalJobItems,CreatedBy.Name from AsyncApexJob ]; 
}

  public void sheduleClicked () 
  {
    {
             System.debug('Class Name : ' +className);
        Type t = Type.forName(className); 
        String sch = '0 10 * * * ?';
Id m=system.schedule('one', sch,(Schedulable)t.newInstance());

}
}
}

 The following is my Visual force page

 

<apex:page controller="GetAllApexClasses">
<apex:form >
 <apex:pageBlock >
  <apex:pageBlockTable value="{!apexclassList}" var="apexclass">
   <apex:column headerValue="Class Name" >
   <apex:outputField value="{!apexclass.ApexClassID}"/>
   </apex:column>
   <apex:column headerValue="Completed Date" >
   <apex:outputField value="{!apexclass.CompletedDate}"/>
   </apex:column>
   <apex:column headerValue="Status" >
   <apex:outputField value="{!apexclass.Status}"/>
   </apex:column>
   <apex:column headerValue="Created By" >
   <apex:OutputField value="{!apexclass.CreatedBy.Name}"/>
   </apex:column>
   <apex:column headerValue="CreatedDate" >
   <apex:outputField value="{!apexclass.CreatedDate }"/>
   </apex:column>
   <apex:column headerValue="TotalJobItems">
   <apex:outputField value="{!apexclass.TotalJobItems}"/>
   </apex:column>
   <apex:column headerValue="Schedule ">
   
   <apex:commandButton id="cb1" action="{!sheduleClicked}" value="schedule" rerender="hiddenBlock"> 
       <apex:param name="className" value="{!apexclass.ApexClassID}" assignTo="{!className}"/>
   </apex:commandButton>
   
   </apex:column>
     </apex:pageBlockTable>

</apex:pageBlock>
 <apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>
</apex:form>
</apex:page>

 

 I am not able to reschedule my class and get the following error when i click on Schedule Command button

 

System.NullPointerException: Attempt to de-reference a null object

Error is in expression '{!sheduleClicked}' in page getapexclasses

 

Class.GetAllApexClasses.sheduleClicked: line 88, column 1

Pls help me as it is urgent. Any help would be greatly appreciated.

Thanks in advance

Hi , 

 

I have a requirement where in i need to schedule more than one apex class using system.schedule. The problem with system.schedule is that it takes class name as its one of the parameters. I have many apex classes so i dont need a class name. Instead is there any way to schedule an apex class using class id in system.schedule method...

 

The following is the code i m referring to

 

TestScheduledApexFromTestMethod s = new TestScheduledApexFromTestMethod();
system.debug('------------000000000000000--------------' +s);
String sch = '0 10 * * * ?';
system.schedule('one', sch,s);

 

Here i need to give the class name time and again and it kind of becomes static.

I need to schedule the apex class in a more dynamic way using class id . 

is there any alternate solution to schedule more than one apex class with one system.schedule method

HI,

 

  I have a visual force page which displays the list of scheduled Apex jobs. Now there is a schedule button. Onclick of the Schedule button , i need the class to be rescheduled to a value.

 

I m getting an INVALID Constructor error when i try to do this.

 

The following is my Controller code:

 

public class GetAllApexClasses {

       
    public  scheduleClicked () {
        return null;
    }


    public String asyncapexjob { get; set; }

    
    public List<AsyncApexJob> apexclassList{get;set;}
    public GetAllApexClasses(){
    apexclassList = new List<AsyncApexJob>();
    apexclassList = [SELECT ApexClassID, Id, CompletedDate,Status,CreatedDate,TotalJobItems,CreatedBy.Name  from 

AsyncApexJob];
}
public  sheduleClicked () 
{
 

   sheduleClicked p = new sheduleClicked();
        String sch = '0 0 8 13 2 ?';
        system.schedule('One Time Pro', sch, p);
 }
}

 The Following is my VF page code

 

<apex:page controller="GetAllApexClasses">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!apexclassList}" var="apexclass">
<apex:column headerValue="Class Name" >
<apex:outputField value="{!apexclass.ApexClassID}"/></apex:column>
<apex:column headerValue="Completed Date" >
<apex:outputField value="{!apexclass.CompletedDate}"/></apex:column>
<apex:column headerValue="Status" >
<apex:outputField value="{!apexclass.Status}"/>
</apex:column>
<apex:column headerValue="Created By" >
<apex:OutputField value="{!apexclass.CreatedBy.Name}"/>
</apex:column>
<apex:column headerValue="CreatedDate" >
<apex:outputField value="{!apexclass.CreatedDate }"/>
</apex:column>
<apex:column headerValue="TotalJobItems">
<apex:outputField value="{!apexclass.TotalJobItems}"/>
</apex:column>
 <apex:column headerValue="Schedule ">
 
 <apex:commandButton id="cb1" action="{!sheduleClicked}" value="schedule" /> 
  
   
  
 
 </apex:column> 
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 The following is the error which i m getting.

 

Error: GetAllApexClasses Compile Error: Invalid constructor name: scheduleClicked at line 4 column 13

 

 

Hi , i have created a custom VF controller which fetches some details of "Scheduled Apex Jobs" from AsyncApexJob object.

 

In My query i m not able to get the Apex job id from AsyncApex object. it Throws an error  "Job id column" does not exists in AsyncApex job object  But when i see it salesforce standard UI , i can see a column called "Job ID"in Scheduled Apex Monitor.   From  Where can i get the Apex Job Id of Scheduled Apex. Also if it is not there in AsyncApexJob object , then where(in which object) is this apex job id stored. Important point to note is  " I m just using scheduled apex and not Batch Apex." 

 

Pls help

HI i have a requirement where i have to get the list of all scheduled apex classes that are in my organization. Any help with respect to this regards will be greatly appreciated. Thanks in advance

Hi , 

 

 I have a requirement wherein i need to retrieve a list of all the apex classes that are available in my org in a custom visual force page. So wht shall i do to achive this. Wht will be controller of that particular  visualforce page. How can i get list of all apex classes in my organisation. 

 

Any sort of  help would be greatly appreciated. Thanks in advance.

 

Hi , 

 

 I have 2 buttons button 1 and button 2. Each of the button has its own page with its sets of field.  Now my requirement goes as belows.

 

If i edit a field value in button 1 's  page and then i click button 2 to navigate , then the color of the button 1 should be changed to yellow which will indicate me that some field value in the page which is associated with button 2 has been edited

 

How do i achieve this ?

I want to send email notification to user, through trigger or any other way, as soon as the attachment is attached to record in Account object.

Hi , can someone provide me with the test class for the following trigger. I have never written any test class before this. so please help me out trigger leadAutoConvert on Lead (after insert) { Database.LeadConvert[] conversions = new Database.LeadConvert[0]; LeadStatus status = [SELECT Id,MasterLabel FROM LeadStatus WHERE IsConverted = TRUE LIMIT 1]; for(Lead record:Trigger.new) { Database.LeadConvert convert = new Database.LeadConvert(); convert.setLeadId(record.Id); convert.setDoNotCreateOpportunity(true); convert.setConvertedStatus(status.MasterLabel); conversions.add(convert); } Database.LeadConvertResult[] results = Database.convertLead(conversions,false); for( Integer i = 0; i < results.Size(); i ++ ) { System.debug('lead Conversion Status leadsToConvert['+i+']'+ results[i].isSuccess()); } }

 

 

Hi i need a Lead Conversion Trigger code. The Trigger should automatically convert the leads to account. It should be an after insert trigger. Since i m new to apex development i am requesting you people to provide me the exact full code.

 

Also the Exact Skeleton of How the trigger should work is given below.

 

Please find the exact details/skeleton of lead conversion 

Trigger on Lead
Trigger on lead( after insert)
{
Get the trigger size (Integer)-

take list of type <database.leadStatus>---this list is used to hold the leads that needs to be converted

Query the lead Status  Isconverted=true(where condition)[ id,Masterlable, should be fetched]

iterate For( i=0;<triggerSize;i++)

{
Create new instance of database.leadconvert
 
set the following values to instance 

set the leadID("id from trigger"),
notCreateOpportunity to(" true")
set convertedstatus(this value from the leadStatus Query)

after setting the values to instance add it to the list of type<database.leadStatus>-declared at the top
}


//create Database.LeadConvertResult[] array — Shown below [you can use exact line shown below]

Database.LeadConvertResult[] leadResult= Database.convertLead(pass the listOfleads that needs to be converted,false);


//itereate the leadResult and check the system.debug to know the success or failure

 

Hi i need a Lead conversion trigger code to convert lead to account/contact. The trigger should use standard database.leadconvert() method. The following is the skeleton of how the trigger should work. Please give me the code asap as it is urgent Please find the details of lead conversion Trigger on Lead Trigger on lead( after insert) { Get the trigger size (Integer)- takelist of type ---this list is used to hold the leads that needs to be converted Query the lead Status Isconverted=true(where condition)[ id,Masterlable, should be fetched] iterate For( i=0;-declared at the top } //create Database.LeadConvertResult[] array—Shown below [you can use exact line shown below] Database.LeadConvertResult[] leadResult= Database.convertLead(pass the listOfleads that needs to be converted,false); //itereate the leadResult and check the system.debug to know the success or failure

i need a trigger code which will convert the lead into account automatically. 

Hi,

i need to write test class for the below mentioned class. This class sends Email to contacts of Accounts whose installed product is due for maintainence in the near future.

Pls help me write test class for this.


global class SendMail {
public List<Preventive_Maintenance_Coverage__c> installprods;
List<String> lcontactEmails = new List<String>();
List<Contact> con = new List<Contact>();
Set<ID> listofIDsToProcess = new Set<ID>();
public Date t = System.today();
public Date criteria;



        public SendMail(){
                           installprods = this.Findinstallprods();
                          // installprods.clear();
                         }
  
   

public List<Preventive_Maintenance_Coverage__c> Findinstallprods() {
   // query to find only the cases that match your conditions requiring email alerts to be sent


   installprods = [select id, Installed_Product__r.Name,Installed_Product__r.Date_Installed__c,frequency__c from Preventive_Maintenance_Coverage__c];

    for(Preventive_Maintenance_Coverage__c p : installprods)
            {
                Integer frequencyval = Integer.valueOf(String.valueOf(Math.roundToLong(P.frequency__c )));
                if(p.Installed_Product__r.Date_Installed__c + frequencyval - 5 == t)
                    {
                         listofIDsToProcess.add(p.Id);
                          system.debug('ID TO PROCESS' + listofIDsToProcess);
                    }
            }
   return installprods;
}
    
   List<Account> accList  = [SELECT id,(SELECT Email FROM Contacts) FROM Account WHERE id IN (SELECT Account__c FROM Installed_Product__c WHERE Id IN: listofIDsToProcess)];
   {
            if(accList.size() > 0) {
        for(Contact con : accList[0].contacts){
          
           if(!String.isBlank(con.Email)){
               lcontactEmails.add(con.Email);
            }
        }
        }
        if(!lcontactEmails.isEmpty()){
            sendEmail(lcontactEmails); 
        }
    }

public static void sendEmail (List<String> toAddress){
    
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        //set the email properties
        mail.setToAddresses(toAddress);
        mail.setSenderDisplayName('SF.com Email Agent');
        mail.setSubject('A new reminder');
        mail.setHtmlBody('Service Maintaince Reminder .');
    
        //send the email
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail } );
      }

}
Hi,

 i need to write test class for the below mentioned class. This class displays the case milestone resolution target time. 
Pls help me write test class for this. 


Class code:- 

public class Clock {
Public String  casename {get;set;}
    public String getCaseMilestone() {
        return null;
    }


    public Clock() {

    }


List<CaseMilestone> sr = new List<CaseMilestone>();
List<CaseMilestone> srresponse = new List<CaseMilestone>();
ID myId;
public Datetime targetDate{get;set;}
public Datetime targetResponseDate{get;set;}

public Clock(ApexPages.StandardController controller) {
   myId = ApexPages.CurrentPage().getParameters().get('id');
  
   sr = [select TargetDate from CaseMilestone where CaseId =: myId and MilestoneTypeId ='557900000008Orj'];
srresponse = [Select TargetDate from CaseMilestone where CaseId =: myId and MilestoneTypeId ='557900000008OrU'];
  
   for(CaseMilestone s1 : sr)
   {
       targetDate  = s1.TargetDate;
    
   }
  
   for(CaseMilestone s2 : srresponse)
   {
       targetResponseDate  = s2.TargetDate;  
    }
  }
}

Hi , 

 

I have a requirement where in i need to reschedule already scheduled apex classes. I have used System.Schedule method to achieve the same. Since System.Schedule only works with the class names(Need to give classname as a third parameter) and since that would become static , i tried using "Reflection concept of java" so that i can pass the instance of an object as a parameter and thus make it work for more than one class. (I have more than once class to schedule in my organisation). 

 

I get an error which states "Attempt to de-reference a null object"

 

The following is my Controller code. 

 

global with sharing class GetAllApexClasses {
    public PageReference shedulerClicked() {
        return null;
    }
public void scheduleClicked () {
        return ;
    }
    public String asyncapexjob { get; set; }
    public string className { get; set; }
    public String schedule  { get; set; }  
    public List<AsyncApexJob> apexclassList{get; set;}
    public List<ApexClass> classList{get;set;}
    public List<CronTrigger> CronList{get;set;}
    
    public GetAllApexClasses(){    
    apexclassList = new List<AsyncApexJob>();
    apexclassList = [SELECT ApexClassID, CompletedDate,Status,CreatedDate,TotalJobItems,CreatedBy.Name from AsyncApexJob ]; 
}

  public void sheduleClicked () 
  {
    {
             System.debug('Class Name : ' +className);
        Type t = Type.forName(className); 
        String sch = '0 10 * * * ?';
Id m=system.schedule('one', sch,(Schedulable)t.newInstance());

}
}
}

 The following is my Visual force page

 

<apex:page controller="GetAllApexClasses">
<apex:form >
 <apex:pageBlock >
  <apex:pageBlockTable value="{!apexclassList}" var="apexclass">
   <apex:column headerValue="Class Name" >
   <apex:outputField value="{!apexclass.ApexClassID}"/>
   </apex:column>
   <apex:column headerValue="Completed Date" >
   <apex:outputField value="{!apexclass.CompletedDate}"/>
   </apex:column>
   <apex:column headerValue="Status" >
   <apex:outputField value="{!apexclass.Status}"/>
   </apex:column>
   <apex:column headerValue="Created By" >
   <apex:OutputField value="{!apexclass.CreatedBy.Name}"/>
   </apex:column>
   <apex:column headerValue="CreatedDate" >
   <apex:outputField value="{!apexclass.CreatedDate }"/>
   </apex:column>
   <apex:column headerValue="TotalJobItems">
   <apex:outputField value="{!apexclass.TotalJobItems}"/>
   </apex:column>
   <apex:column headerValue="Schedule ">
   
   <apex:commandButton id="cb1" action="{!sheduleClicked}" value="schedule" rerender="hiddenBlock"> 
       <apex:param name="className" value="{!apexclass.ApexClassID}" assignTo="{!className}"/>
   </apex:commandButton>
   
   </apex:column>
     </apex:pageBlockTable>

</apex:pageBlock>
 <apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>
</apex:form>
</apex:page>

 

 I am not able to reschedule my class and get the following error when i click on Schedule Command button

 

System.NullPointerException: Attempt to de-reference a null object

Error is in expression '{!sheduleClicked}' in page getapexclasses

 

Class.GetAllApexClasses.sheduleClicked: line 88, column 1

Pls help me as it is urgent. Any help would be greatly appreciated.

Thanks in advance

Hi , i have created a custom VF controller which fetches some details of "Scheduled Apex Jobs" from AsyncApexJob object.

 

In My query i m not able to get the Apex job id from AsyncApex object. it Throws an error  "Job id column" does not exists in AsyncApex job object  But when i see it salesforce standard UI , i can see a column called "Job ID"in Scheduled Apex Monitor.   From  Where can i get the Apex Job Id of Scheduled Apex. Also if it is not there in AsyncApexJob object , then where(in which object) is this apex job id stored. Important point to note is  " I m just using scheduled apex and not Batch Apex." 

 

Pls help

Hi i need a Lead Conversion Trigger code. The Trigger should automatically convert the leads to account. It should be an after insert trigger. Since i m new to apex development i am requesting you people to provide me the exact full code.

 

Also the Exact Skeleton of How the trigger should work is given below.

 

Please find the exact details/skeleton of lead conversion 

Trigger on Lead
Trigger on lead( after insert)
{
Get the trigger size (Integer)-

take list of type <database.leadStatus>---this list is used to hold the leads that needs to be converted

Query the lead Status  Isconverted=true(where condition)[ id,Masterlable, should be fetched]

iterate For( i=0;<triggerSize;i++)

{
Create new instance of database.leadconvert
 
set the following values to instance 

set the leadID("id from trigger"),
notCreateOpportunity to(" true")
set convertedstatus(this value from the leadStatus Query)

after setting the values to instance add it to the list of type<database.leadStatus>-declared at the top
}


//create Database.LeadConvertResult[] array — Shown below [you can use exact line shown below]

Database.LeadConvertResult[] leadResult= Database.convertLead(pass the listOfleads that needs to be converted,false);


//itereate the leadResult and check the system.debug to know the success or failure

 

Hi i need a Lead conversion trigger code to convert lead to account/contact. The trigger should use standard database.leadconvert() method. The following is the skeleton of how the trigger should work. Please give me the code asap as it is urgent Please find the details of lead conversion Trigger on Lead Trigger on lead( after insert) { Get the trigger size (Integer)- takelist of type ---this list is used to hold the leads that needs to be converted Query the lead Status Isconverted=true(where condition)[ id,Masterlable, should be fetched] iterate For( i=0;-declared at the top } //create Database.LeadConvertResult[] array—Shown below [you can use exact line shown below] Database.LeadConvertResult[] leadResult= Database.convertLead(pass the listOfleads that needs to be converted,false); //itereate the leadResult and check the system.debug to know the success or failure

i need a trigger code which will convert the lead into account automatically.