How to capture richline text and empty fields in notifications
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 05:04 AM
the below code is just capturing question and answer ( if the field is not empty) , how to modify this code so that it has to capture question which are empty fields along with which are not empty and rich text label also.
function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.request_item.sys_id);
set.load();
var vs = set.getFlatQuestions();
for (var i = 0; i < vs.size(); i++) {
if (vs.get(i).getDisplayValue() != '' && +vs.get(i).getLabel() != '') {
template.print(vs.get(i).getLabel() + "::" + vs.get(i).getDisplayValue());
template.print("\n");
}
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 04:10 AM
Hello @User_267 ,
Update and try this one:
function runMailScript(current, template, email, email_action, event) {
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.request_item.sys_id);
set.load();
var vs = set.getFlatQuestions();
for (var i = 0; i < vs.size(); i++) {
var question = vs.get(i);
var label = question.getLabel();
var displayValue = question.getDisplayValue();
// Including both empty and non-empty fields along with rich text labels
if (label) {
template.print(label + "::" + (displayValue ? displayValue : "No Answer Provided"));
template.print("\n");
}
}
}
runMailScript(current, template, email, email_action, event);
Thank you!!
Dnyaneshwaree Satpute
Tera Guru