Skip to main content
Participant
October 17, 2011
Answered

Is there any way to add scheduled tasks through the CFAdmin API?

  • October 17, 2011
  • 1 reply
  • 1192 views

I have a bunch (over 50) that I need to add in our development environment... I've really found the ability to add event gateways and DSNs through the API to be very helpful in this environment, so I decided to try the same for scheduled tasks.

Looks like it is not as well documented... here is my code:

<cfscript>

    // Login to CF Adminapi

    adminObj = createObject("component","cfide.adminapi.administrator");

    adminObj.login("admin");

    // instantiate servermanager obj

    evObj = createObject("component","cfide.adminapi._servermanager.servermanager");

   

    // instantiate scheduledwrapper obj

    swrapObj = createObject("component","cfide.adminapi._servermanager.schedulerwrapper");

    swrapObj.init();

   

    taskStruct = StructNew();

    StructInsert(taskStruct,"taskname","testSpoolCleaner");

    StructInsert(taskStruct,"dwminterval","daily");

    StructInsert(taskStruct,"scheduletype","recurring");

    StructInsert(taskStruct,"start_date",createDateTime(2011,10,18,1,0,0));

    StructInsert(taskStruct,"scheduledURL","http://<my url>");

    // too bad... looks like the rest of the methods I need are private to Coldfusion; can't access them.. It says method not found.

    popWrapper = swrapObj.populateSchedulerWrapper(taskStruct);

    setTask = evObj.setScheduledTasks(swrapObj);   

       

</cfscript>

Google returns no references to anyone attempting this... help?

This topic has been closed for replies.
Correct answer Charlie Arehart

Though the Admin API is indeed the way to go for programming most Admin functions, it’s got its issues, as you’ve found.

In your case, though, you’re in luck: long before the Admin API was added (in CF7), there was (and still is) the simple, old school CFSCHEDULE tag. Let us know if that works for you instead.

/charlie

1 reply

Charlie Arehart
Community Expert
Charlie ArehartCommunity ExpertCorrect answer
Community Expert
October 17, 2011

Though the Admin API is indeed the way to go for programming most Admin functions, it’s got its issues, as you’ve found.

In your case, though, you’re in luck: long before the Admin API was added (in CF7), there was (and still is) the simple, old school CFSCHEDULE tag. Let us know if that works for you instead.

/charlie

/Charlie (troubleshooter, carehart. org)
Participant
October 19, 2011

Ha! So caught up in the API I forgot about that. Thanks, Charlie!