hub.eb?material_id=420&track_id=419

Introduction to Scheduled Tasks


A scheduled task is a mechanism for performing an action according to a predefined schedule.

To create a Scheduled Task, right-click the entities tree and select New > Scheduled Task.

Scheduled Tasks

The Program Information section is used to select the Program and to specify any parameters, such as the name of the form to run. When you specify a form to run, the Before Form and After Form events will be triggered. Other events will not be triggered.

If the target form includes URL Parameter fields, values for these can also be specified using the Form parameter section. This section is hidden when no URL Parameter fields are defined.

The Schedule Information section is then used to specify when the Program is run.

Steps


1

 

// Before Form
// This script generates a report and saves it
// to a text file with a unique name.

// Fetch the sales table
// This contains product name, sale dates and cost
var rows = tables.sales.fetchTable(true);

// Build the report as an array
// Each line is tab-separated
var report = [];
while (rows.next()) {
  report.push(
    tables.sales.saleDate.value + "\t" +
    tables.sales.product.value + "\t" + 
    "£" + tables.sales.cost.value
  );
}

// Write the report to a file
var fileName = new Date() + "report.txt";
services.file.writeFile(fileName, report.join("\n"));

Current Module

Related