Send an alert email when a scheduled script completes

This script informs a user when a scheduled script completes successfully.

Follow the steps below or download the solutions file, see Creating Solutions for details.

Setup

  1. Create a new Scheduled script deployment.

  2. Enter a Filename and click SAVE. The extension ‘.js’ is automatically appended if not supplied.

  3. Click on the script link to launch the Scripting Studio.

  4. (1) Copy the Program Listing below into the editor, (2) set the Schedule event, and set main as the Entrance Function.

    Scripting Studio tools and settings panel showing the form association, the user event association and the selected entrance function.

Program Listing

          function main() {
    // TODO Add Your Code Here

    // TODO Handle Errors

    // Notify The Owner
    var me = NSOA.wsapi.whoami();
    var msg = {
        to: [me.id],
        subject: "Script completed",
        format: "HTML",
        body: "<b>Your script completed</b><br/>" +
              "<hr/><i>Automatically sent by the system</i>"
    };

    NSOA.meta.sendMail(msg);
}