• Suman sfdc
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies
Hello,

This is my first post, please help me on the below issue. 
There is a custom object which stores the Schedulable Apex Classes. Requirement is to create a Schedulable apex jobs for all of them using System.schedule method but it allows only instace of a Schedulable apex class as a input parameter, below is my code. Please advise how to create a dynamic instace for the sch.apex class which is available at run time in variable wa.Apex_Class__c.

QJobsList = [SELECT id, Name,  Job_Name__c, Apex_Class__c FROM Schedule_Apex__c ];
for(Schedule_Apex__c wa : QJobsList){
                wa.Apex_Class__c  Obj  = new wa.Apex_Class__c();  //This Statment is not working, Seems to be a dynamic assignment is required 
                    //Cron Expression
                    String sch = '0 0 0 '+ wa.Scheduled_Date__c.day() + ' ' + wa.Scheduled_Date__c.month() + ' ? ' + wa.Scheduled_Date__c.year(); //
            
                    System.schedule( 'Test job1' , sch , Obj);
}

If i can give write like this  TestSchApxJob  c = new TestSchApxJob();  //schedulable apex class name, there is no error but it's not possible 
I have googled this and found i can use something like below but still not able to understand. 
// Get the Type corresponding to the class name
Type t = Type.forName(cs.className__c);

Thanks in advance for your help,
Suman

      
                      
Hello,

This is my first post, please help me on the below issue. 
There is a custom object which stores the Schedulable Apex Classes. Requirement is to create a Schedulable apex jobs for all of them using System.schedule method but it allows only instace of a Schedulable apex class as a input parameter, below is my code. Please advise how to create a dynamic instace for the sch.apex class which is available at run time in variable wa.Apex_Class__c.

QJobsList = [SELECT id, Name,  Job_Name__c, Apex_Class__c FROM Schedule_Apex__c ];
for(Schedule_Apex__c wa : QJobsList){
                wa.Apex_Class__c  Obj  = new wa.Apex_Class__c();  //This Statment is not working, Seems to be a dynamic assignment is required 
                    //Cron Expression
                    String sch = '0 0 0 '+ wa.Scheduled_Date__c.day() + ' ' + wa.Scheduled_Date__c.month() + ' ? ' + wa.Scheduled_Date__c.year(); //
            
                    System.schedule( 'Test job1' , sch , Obj);
}

If i can give write like this  TestSchApxJob  c = new TestSchApxJob();  //schedulable apex class name, there is no error but it's not possible 
I have googled this and found i can use something like below but still not able to understand. 
// Get the Type corresponding to the class name
Type t = Type.forName(cs.className__c);

Thanks in advance for your help,
Suman

      
                      

 i need to pass selected value with ' ' in the following string but i am unable to do so

 String query='select column_name from information_schema.COLUMNS where table_name ='+ selectedValue1;

 my debug log shows the below mentioned statement

select column_name from information_schema.COLUMNS where table_name =RegistrationTable

 but the actual required statement should be 

select column_name from information_schema.COLUMNS where table_name ='RegistrationTable'

 how do i prepare my string variable. As Sfdc is not allowing me to use "" to prepare the string.