Scheduling an Event with the CFSCHEDULE Tag ColdFusion Help

Using the CFSCHEDULE tag, you can schedule events as yoti did through the ColdFusion Administrator as well as perform management tasks such as deleting scheduled jobs. These management tasks are discussed later in the section “Managing and Logging Scheduled Events.”

The role that the CFSCHEDULE tag will play is determined by the value of the ACTION attribute:

Update Creates a new task or changes the settings of an existing task.
Delete Deletes an existing task.
Run Executes ~ existing task,
In this section, you will look at’how to use CFSCHEDULE with ACTION-Update. The possible attributes of the CFSCHEDULE tag when ACTION-Update is used are outlined in the following list. All the attributes correspond to information provided when creating a task by using the ColdFusion Administrator.

TASK Name of the task being updated .
OPERATION Type of operation to perform when executing this task; currently, the only possible value is HTIPRequest, and this value should be specified.
FILE Filename in which to store the output of the task if PUBLISH-Yesis set.
PATH .Path of the directory where the output of the task should be stored if PUBLISH-Yesis set.
STARTDATE The date ~hen the scheduled task should start.
STARTTME The time when the scheduled task should start.
URL The URL to be executed.

To better understand how the CFSCHEDULE tag can be applied, consider this example: Imagine th.at an organization has three database reports (called Report I, Report 2, and Report 3) that employees use in their work. The organization wants to create a Web page that employees can use to schedule the reports to run overnight so they are available in the morning when they need them. To build this application, you first need to define a few guidelines:

When a user runs a report, they want the output stored in their home . Home directories are located at \ \homedir server\username.

The Web site is password protected so that only valid users can schedule the reports. This prevents you from having to deal with authentication in your templetes.

The reports should be scheduled to run at 11:00 P.M. on the day they are requested. Given these assumptions, the application will consist of two pages

form.cfm. Presents a form on which the user can request that a report be scheduled
schedule.cfm. Schedules the job as specified by the user, and then displays a confirmation notice for the user

The structure of this file is fairly simple; it contains only trail forward HTML. The form has two fields: a select list to choose the report and a field to specify the username of the user requesting the report. This provides all information you need to schedule the task.

Again, the code in this template is fairly simple. The only ColdFusion tag used is the CFSCHEDULE tag. The important attributes are:

TASK The name of the task is built out of a combination of the username and the selected report to make tasks easy to identify.
URL The URL is built from tl e value of Form. report.
FILE The filename is derived from the report name so the user can find it easily the next day.
PATH The path is derived from the value of Form. username.
STARTDATE and ENDDATE You use the NowO function to obtain the current date and then MonthO, DayO, and YearO to return values for the current date.
The start date and p d date are set the same so that the event occurs only on that day.
INTERVAL The :value is set to Daily to make it occur once, only on the start date.

Posted on November 16, 2015 in Scheduling Events

Share the Story

Back to Top
Share This