Awaken Scripting User Guide

Please email helpdesk@awaken.io for omissions or errors.
×
Menu

JavaScript Reschedules

 
To easily reschedule a Workflow run, the following Helper Functions can be used. They automatically close the Workflow run as soon as they have successfully submitted the reschedule, and the reschedule will be resumed from the same Page that it was triggered from.
 
All of the functions feature an optional "callback" function that can be included to execute further code when the function has either successfully completed or failed. These won't be specifically mentioned in each function, but are always the final parameter.
 

How To

There are three functions allowing specific classes of reschedule (To All, To Group, and To User), as well as a generic reschedule function allowing customised behaviour depending on the passed parameters.
 
Name
Description
Code
Script.RescheduleToAll
Reschedules the current Workflow run to all Users, being accessible through the outstanding record list in the Campaign view when it becomes due.
 
The first parameter is a string of the outcome.
The second parameter is the date and time that the reschedule will become due. Can either be provided as a JavaScript Date object, or a string in the form "YYYY-MM-DD hh:mm:ss", "YYYY-MM-DD hh:mm", or "YYYY-MM-DD".
Reschedule to all agents immediately.
Script.RescheduleToAll(
    "Rescheduled (All)",
    new Date(),
    function(response) {
        if (!response.Success) {
            alert(response.ErrorMessage);
        }
    }
);
Script.RescheduleToGroup
Reschedules the current Workflow run to all Users in a specified Group, being accessible through the outstanding record list in the Campaign view and the outstanding tasks list when it becomes due.
 
The first parameter is a string of the outcome.
The second parameter is the date and time that the reschedule will become due. Can either be provided as a JavaScript Date object, or a string in the form "YYYY-MM-DD hh:mm:ss", "YYYY-MM-DD hh:mm", or "YYYY-MM-DD".
The third parameter is the ID of the Group for the record to be rescheduled to.
Reschedule to the specified Group immediately.
Script.RescheduleToGroup(
    "Rescheduled (Group)",
    new Date(),
    [Group ID],
    function(response) {
        if (!response.Success) {
            alert(response.ErrorMessage);
        }
    }
);
Script.RescheduleToUser
Reschedules the current Workflow run to a specific User, being accessible through the outstanding record list in the Campaign view and the outstanding tasks list when it becomes due.
 
The first parameter is a string of the outcome.
The second parameter is the date and time that the reschedule will become due. Can either be provided as a JavaScript Date object, or a string in the form "YYYY-MM-DD hh:mm:ss", "YYYY-MM-DD hh:mm", or "YYYY-MM-DD".
The third parameter is the ID of the User for the record to be rescheduled to.
Reschedule to the specified User in 24 hours time.
var date = new Date();
date.setDate(date.getDate() + 1);
 
Script.RescheduleToUser(
    "Rescheduled (User)",
    date,
    [User ID],
    function(response) {
        if (!response.Success) {
            alert(response.ErrorMessage);
        }
    }
);
Script.Reschedule
Accepts a single JavaScript object as a parameter, with that object containing any keys and values that you want to use to specify the reschedule. Note that if both a userid and groupid are specified, then the groupid will be ignored.
 
outcome: A string of the outcome for the current Workflow run, to be used upon its closure.
datetime: The date and time that the reschedule will become due. Can either be provided as a JavaScript Date object, or a string in the form "YYYY-MM-DD hh:mm:ss", "YYYY-MM-DD hh:mm", or "YYYY-MM-DD".
userid: A string or integer of the ID of the User to be rescheduled to. If rescheduling to All Users or a specific Group, this should equal 0.
groupid: A string or integer of the ID of the Group to be rescheduled to. If rescheduling to All Users or a specific User, this should equal 0.
comments (Optional): A string that will be included in the Campaign View's record history.
callback (Optional): The optional callback function.
Reschedules to the current agent in 15 minutes.
var date = new Date();
date.setMinutes(date.getMinutes() + 15);
 
Script.Reschedule({
    outcome:"Rescheduled (AoR)",
    datetime:date,
    userid:[var_csAgentId],
    groupid:0,
    callback: function(response) {
        if (!response.Success) {
            alert(response.ErrorMessage);
        }
    }
});
 
 

Notes

The callback response consists of a JavaScript object with the following structure:
 
{
    Success: true,      // This is a boolean of whether the reschedule was made or not
    Error: "",          // This is blank, unless an error occurs
    ErrorMessage: "",   // This is blank, unless an error occurs
    Id: "200"           // This is the Outbound ID for the record being rescheduled
}