Workflow activity not returning output of lists to the Business Application form
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2023 06:21 AM
I've got a catalogue item that allows users to select if a control is Compliant or Non Compliant. When a user raises a request, I'm wanting to return the list of controls that were updated as part of the requested item. I'm trying to return the results in two lists:
- Closed Controls
- Updated Controls
I'm using the following code in my workflow to deliver the results:
var closedControls = [];
var updatedControls = [];
var workNotes = "The following AMA controls have been updated by " + current.u_requested_for.name + " as part of " + current.number +". Please refer to the RITM for full details.\n\n";
var controls = current.variables.ama_controls;
for (var i; i < controls.getRowCount(); i++){
var control_name = new GlideRecord('question_choice');
control_name.addEncodedQuery('question=e1b53c2f1b63c19033e1dbd6b04bcb47');
control_name.addQuery('value', controls[i].getValue('value'));
control_name.query();
if(control_name.next()) {
if (controls[i].compliant_for_selected_control == 'Yes') {
closedControls.push(controls[i]);
gs.log('MH The length of closedControls is ' + closedControls.length());
}
else{
updatedControls.push(controls[i]);
gs.log('MH The length of updatedControls is ' + closedControls.length());
}
}
}
var busApp = current.variables.select_the_application_to_update;
var grBAnotes = new GlideRecord('cmdb_ci_business_app');
if (grBAnotes.get(busApp)) {
if(closedControls.length > 0 && updatedControls.length > 0){
workNotes += "Closed Controls:\n";
workNotes += closedControls.join("\n\n");
workNotes += "Updated Controls:\n";
workNotes += updatedControls.join("\n");
}
if(closedControls.length > 0 && updatedControls.length == 0){
workNotes += "Closed Controls:\n";
workNotes += closedControls.join("\n");
}
if(updatedControls.length > 0 && ClosedControls.length == 0){
workNotes += "Updated Controls:\n";
workNotes += updatedControls.join("\n");
}
}
grBAnotes.work_notes = workNotes;
grBAnotes.update();
However, when a request is raised, only the following appears on the work notes of a Business Application:
I was just wondering if somebody could explain what's going wrong with my code.
0 REPLIES 0