+ Start a Discussion
SalesForce DummySalesForce Dummy 

Issues with system.schedule parameters

I'm attempting to create a scheduled job programatically using system.schedule but I'm running into issues. I'm trying to pass the parameters "Schedule Name",  "Schedule Time" and "Class Name" from strings from an object in SFDC. The problem is I don't know exactly how to change a string into an object. 

This is what I have so far:
 
 //Iterate through list of job descriptions
 For(Manage_ScheduleJobs__c addJobs : schJobs)
 {
 //Get class name and job name
 string ClassName = addJobs.Class_Name__c;
 string jobName = addJobs.Job_Name__c;
 
 //Attempt to change string to class
 object classDev = ClassName;

//Get the id of the new scheduled job
Id jobId = System.schedule(jobName, '0 0 0 * * ?', new classDev());
}
What am I doing wrong?
Thanks.

 

Best Answer chosen by Admin (Salesforce Developers) 
Osiris77706Osiris77706

can ClassName be passed as a paremeter to the classdev object ? the problem is that you cant assign an object the value of a string. is there a specific variable of classdev that can hold the value of ClassName ? or perhaps casting the string as an object could work, but i have my doubts. the line of code would have to be more like this:

 

classDev.[*/Specific Element Here /*] = ClassName

All Answers

Osiris77706Osiris77706

can ClassName be passed as a paremeter to the classdev object ? the problem is that you cant assign an object the value of a string. is there a specific variable of classdev that can hold the value of ClassName ? or perhaps casting the string as an object could work, but i have my doubts. the line of code would have to be more like this:

 

classDev.[*/Specific Element Here /*] = ClassName

This was selected as the best answer
SalesForce DummySalesForce Dummy

OK. I'm at a loss. What I'm trying to do is allow our admins to schedule our Apex classes via a custom object. They input the necessary parameters like time, class name, job name, etc. I then created a new Apex class that pulls the values from the custom object to construct the systems.schedule method parameters. Is there any way to take a string from the custom object and implement a class based on the value of the string?

SalesForce DummySalesForce Dummy

I found the answer and it's a resounding no. However, it is on IdeaExchange so, hopefully, it will be implemented soon.

 

http://sites.force.com/ideaexchange/apex/ideaview?id=08730000000J5QfAAK

Osiris77706Osiris77706

Ahhh, i see. Forgive me i think i misunderstood the problem.