January 13, 2016, 2:52 pm - James Farrer
I ran into a problem today where I needed a summary of requested item variables to send out in an email notification. I didn't see a good script for doing it but found a number that were close. Here's my version that does some checking to only show variables that would normally have content suitable to a summary. I'm sure there's room for additional improvement but for the time being this did the trick:
function printVariableSummary(){
// Variable types that shouldn't be shown
hidden_types = {
12:true,
20:true,
24:true,
19:true,
11:true,
14:true,
17:true,
25:true,
15:true
};
template.print('<strong>Item Options</strong><br/>');
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.sys_id);
set.load();
var vs = set.getFlatQuestions();
// Go through all the variables
for (var i=0; i < vs.size(); i++) {
// Skip variables without a label or that are a type that should be skipped
if(vs.get(i).getLabel() != '' && !hidden_types[vs.get(i).getType()]) {
template.space(4);
template.print(' <strong>' + vs.get(i).getLabel() + ":</strong> " + vs.get(i).getDisplayValue() + "<br />");
}
}
}
printVariableSummary();