KBEC-00091 - Listing nested job steps data in email notifications

Summary

Html_JobTempl.txt (located with other email notification templates in src/samples/notifier) is a job notifier that creates an email with overall job information, as well as step-specific data.
One caveat: for a given job, it displays the very top set of steps only. Therefore it will not be very useful if you have multiple nested subprocedure calls.

Solution

Instead of listing job steps in a single call, create a function that calls itself recursively as it finds more subprocedure steps.

Examples


$[/javascript

// Define a function that will expand the steps at the given level
function expandSteps(steps, level) {

var res = new String("");
for (var stepName in steps) {

var thisStep = steps[stepName];
res += " \n";
res += " " + level + "\n";
res += " " + thisStep.name + "\n";
res += " " + thisStep.jobStepId + "\n";
res += " " + thisStep.status + "\n";
if ( thisStep.outcome == 'success' ) {
res += " " + thisStep.outcome + "\n";
}
else if ( thisStep.outcome == 'error' ) {
res += " " + thisStep.outcome + "\n";
}
else if ( thisStep.outcome == 'warning' ) {
res += " " + thisStep.outcome + "\n";
}
else if ( ! thisStep.outcome ) {
res += " " + "-" + "\n";
}
res += " " + thisStep.errorCode + "\n";
res += " " + thisStep.procedureStep.stepName + "\n";
res += " " + thisStep.start + "\n";
res += " " + thisStep.finish + "\n";
res += " " + thisStep.subprocedure + "\n";
res += " " + thisStep.logFileName + "\n";
res += " \n";

// Expand substeps recursively
if (thisStep.steps) {
res += expandSteps(thisStep.steps, level+1);
}
}
return (res);
}

var res = new String("\n");
res += "\n";
res += " \n";
res += " \n";
res += " \n";
res += " \n";
res += " \n";
res += " \n";
res += " \n";
res += " \n";
res += " \n";
res += " \n";
res += " \n";
res += " \n";
res += " \n";

res += expandSteps(myJob.steps, 1);
res;

]

Have more questions?

0 Comments

Please sign in to leave a comment.
Job Step LevelJob Step NameJob Step IdStatusOutcomeError CodeProc StepStartFinishSubprocedureLog File Name