KBEC-00185 - Displaying elapsed time of a job in an email notifier

Summary

Q: Current examples of email notifiers do not include the job's elapsed time. Is it available?
A: Yes, it can be accessed as myJob.elapsedTime.

Q: But it is in milliseconds. How can I display it in a human-readable format?
A1: Find a reasonable date conversion function on the Internet.
A2: There is an example of such a function.

Solution

The following code snippet (in Examples) comes from another KB article:

KBEC-00122 - Including Error Diagnostics in a Notifier

However, it may be difficult to locate it there because it lives in the notifierTemplate property inside the procedure.

Examples

$[/javascript...    function quantify (number, noun)    {        if (number == 1) {            // Singular form, no need to add an "s".            return number + " " + noun;        }        return number + " " + noun + "s";    }    var seconds = Math.floor (myJob.elapsedTime / 1000);    var minutes = Math.floor (seconds / 60);    seconds %= 60;    var elapsedString = quantify(seconds, "second");    if (minutes > 0) {        var hours = Math.floor(minutes/60);        minutes %= 60;        elapsedString = quantify(minutes, "minute") + ", " + elapsedString;        if (hours > 0) {            elapsedString = quantify(hours, "hour") + ", " + elapsedString;        }    }...]

See Also

KBEC-00122 - Including Error Diagnostics in a Notifier

Have more questions? Submit a request

Comments

Powered by Zendesk