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 += " <tr>\n";
res += " <td class=\"success\">" + level + "</td>\n";
res += " <td class=\"success\">" + thisStep.name + "</td>\n";
res += " <td class=\"success\">" + thisStep.jobStepId + "</td>\n";
res += " <td class=\"success\">" + thisStep.status + "</td>\n";
if ( thisStep.outcome == 'success' ) {
res += " <td class=\"success\">" + thisStep.outcome + "</td>\n";
}
else if ( thisStep.outcome == 'error' ) {
res += " <td class=\"error\">" + thisStep.outcome + "</td>\n";
}
else if ( thisStep.outcome == 'warning' ) {
res += " <td class=\"warning\">" + thisStep.outcome + "</td>\n";
}
else if ( ! thisStep.outcome ) {
res += " <td class=\"success\">" + "-" + "</td>\n";
}
res += " <td class=\"success\">" + thisStep.errorCode + "</td>\n";
res += " <td class=\"success\">" + thisStep.procedureStep.stepName + "</td>\n";
res += " <td class=\"success\">" + thisStep.start + "</td>\n";
res += " <td class=\"success\">" + thisStep.finish + "</td>\n";
res += " <td class=\"success\">" + thisStep.subprocedure + "</td>\n";
res += " <td class=\"success\">" + thisStep.logFileName + "</td>\n";
res += " </tr>\n";

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

var res = new String("\n");
res += "<table cellspacing=\"1\"=>\n";
res += " <tr class=\"header\">\n";
res += " <td>Job Step Level</td>\n";
res += " <td>Job Step Name</td>\n";
res += " <td>Job Step Id</td>\n";
res += " <td>Status</td>\n";
res += " <td>Outcome</td>\n";
res += " <td>Error Code</td>\n";
res += " <td>Proc Step</td>\n";
res += " <td>Start</td>\n";
res += " <td>Finish</td>\n";
res += " <td>Subprocedure</td>\n";
res += " <td>Log File Name</td>\n";
res += " </tr>\n";

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

]
Have more questions? Submit a request

Comments

Powered by Zendesk