Scheduled Work

Type {{#dataTypeArticle objectTypeId}}{{objectTypeId}}{{/dataTypeArticle}}
Datastore Type {{#dataTypeArticle datastoreTypeId}}{{datastoreTypeId}}{{/dataTypeArticle}}
Supports {{#article "security/authorities"}}authorities{{/article}}, {{#article "security/permissions"}}permissions{{/article}}, {{#article "transfer"}}transfer{{/article}}

Configuration

what frequency and what settings are provided for their described actions. You can adjust this confirmation at any time and supply it when you create, update or query for scheduled work items.

The following table shows the configuration properties:

Property Type Default Read-Only Description
triggerConfig object An object that describes the frequency of the trigger.
{
    "frequency": "{frequency}",
    "day": "{day}",
    "hour": "{hour}",
    "timezone": "{timezone}"
}
            Where <code>frequency</code> a string with one of the following values:
            <br/><br/>
            <ul>
                <li><code>ONCE_EVERY_DAY</code></li>
                <li><code>ONCE_EVERY_MONTH</code></li>
                <li><code>ONCE_EVERY_WEEK</code></li>
                <li><code>FIRST_DAY_OF_MONTH</code></li>
                <li><code>START_OF_EVERY_HOUR</code></li>
            </ul>
            <br/>
            And <code>day</code> is an optional number from <code>1</code> (the first of the month) to <code>31</code> (for monthly specifiers).
            <br/>
            And <code>hour</code> is an optional number from <code>0</code> (midnight) to <code>23</code> (11pm).
            <br/>
            And <code>timezone</code> is a string like <code>EST</code>.
            <br/>
            <br/>
            For <code>ONCE_EVERY_DAY</code>, only the <code>hour</code> can be adjusted.
            <br/>
            For <code>ONCE_EVERY_MONTH</code>, the <code>day</code> and daily <code>hour</code> can be adjusted.
            <br/>
            For <code>ONCE_EVERY_WEEK</code>, the <code>day</code> is used to indicate Monday (<code>1</code>) through Sunday (<code>7</code>).
            <br/>
            For <code>FIRST_DAY_OF_MONTH</code>, the <code>hour</code> can be adjusted.
            <br/>
            For <code>START_OF_EVERY_HOUR</code>, neither <code>day</code> nor <code>hour</code> is supported.
            <br/>
            <br/>
            If not specified, the <code>day</code> is assumed to be the first of the month or the first day of the week, Monday (<code>1</code>).
            <br/>
            If not specified, the <code>hour</code> is assumed to be midnight (<code>0</code>).
        </td>
    </tr>
    <tr>
        <td>actionId</td>
        <td>text</td>
        <td></td>
        <td></td>
        <td>
            The ID of the action to trigger.  For information on actions, please look at the Cloud CMS actions framework.
        </td>
    </tr>
    <tr>
        <td>actionConfig</td>
        <td>object</td>
        <td></td>
        <td></td>
        <td>
            An object providing JSON configuration for the action to trigger.
        </td>
    </tr>
</tbody>

Working with Scheduled Work Items

If you have platform manager rights, you will be able to work with scheduled work items from either the Cloud CMS Administration Console or programatically.

Cloud CMS Administration Console

On the left-hand side, you will see a Scheduled Work page.

[object Object]

From this page, you can list or query for existing scheduled work items. You can also edit existing entries or create brand new scheduled work items.

To create a scheduled work item, click Create. You'll see a form like this:

[object Object]

You can use this form to set all of the properties of your work item. For information on configuring the action that the scheduled work item triggers, please see below.

API

You can create a scheduled work item by simply providing the JSON to configure it:

// the platform
var platform = ...;

// create the scheduled work item
// this runs at 5pm every day (EST)
platform.createScheduledWorkItem({
    "triggerConfig": {
        "frequency": "ONCE_EVERY_DAY",
        "hour": 17,
        "timezone": "EST"
    },
    "actionId": "email",
    "actionConfig": {
        "to": "joe@bloggs.com",
        "body": "Hi Joe!"
    }
}).then(function() {
    // all done
});

To update, simply adjust it's configuration as you see fit. Cloud CMS will automatically adjust any live triggers that are running across the cluster according to your definition.

// assume we have a scheduled work item
var scheduledWorkItem = ...;

// update the schedule
// run at 1pm GMT in the middle of the month
scheduledWorkItem["triggerConfig"]["frequency"] = "ONCE_EVERY_MONTH";
scheduledWorkItem["triggerConfig"]["day"] = 15;
scheduledWorkItem["triggerConfig"]["hour"] = 13;
scheduledWorkItem["triggerConfig"]["timezone"] = "GMT";
// and change the email
scheduledWorkItem["actionConfig"]["body"] = "Hello Joe!";
scheduledWorkItem.update();

And, of course, you can delete scheduled work items.

// assume we have a scheduled work item
var scheduledWorkItem = ...;

// delete it
scheduledWorkItem.del();

You can also list and query for scheduled work items using their JSON properties. Just like anything else in Cloud CMS, lists and queries support pagination, sorting and deeply nested property lookups.

Here is an example of querying for scheduled work items:

// the platform
var platform = ...;

// find all scheduled work items that are running monthly on the 3rd day of the month
platform.queryScheduledWorkItems({
    "triggerConfig.frequency": "ONCE_EVERY_MONTH",
    "triggerConfig.day": 3
}).each(function() {
    console.log("Found: " + this._doc);
});