Add Record Producer Variables in email notification

Brian S5
Kilo Sage

I created a Record Producer with a couple of questions. I created a email notification to trigger on submission and I would like to know how I can include the answers to the variable questions. I've tried a few scripts from posts in the forums where users had a similar issue, however I cant seem to get the logic correct to have the variables show as they aren't visible in the select variables section on the right hand side of the notification message. I tried the links below and a couple of others. So far all I get is a blank notification.

 

 

 

Showing Request Item / Catalog Variables in Mail Script

 

Add request item variables to approval email comments

9 REPLIES 9

Masha
Kilo Guru

what code are you running?


Brian S5
Kilo Sage

Any of the codes in the links I posted. I copied and pasted into my notification message, but I don't know enough about scripting to know which lines to change and then to reference my variables in the email body


Masha
Kilo Guru

I am not sure how to help you without seeing what code your are running.


Brian S5
Kilo Sage

Here is the code i put in the notitication. I plan on taking a scripting class within the next few months and will be attending the knowledge14 conference in May.




template.print('Requested Item Details:\n');
template.print('\n');



var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.sys_id);
set.load();
var vs = set.getFlatQuestions();
for (var i = 0; i < vs.size(); i++) {
var currentVar = vs.get(i);



if (currentVar.getDisplayValue() != 'false' && currentVar.getDisplayValue() != '' && currentVar.getDisplayValue() != '-- None --') {
template.print('\n');
}
}
template.print('



if (currentVar.getDisplayValue() == 'true') {
template.space(2);
template.print(' colspan="2"');
}


template.print('>');
template.print(currentVar.getLabel());


if (currentVar.getDisplayValue() != 'true') {
template.print('
'+ currentVar.getDisplayValue());
}
template.print('

\n');