Variables in the notification by Script include
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Hello, I'm trying to create notifications using the include script that send all the variables from the request or incident to the requester. In other words, every time a request is created, an email is sent to the responsible party with all the variables that have been filled in. Sending the RITM variables is working, but the incident notification is returning the values of the variables. Could someone help me figure out where the problem is?
var variablesHtml = this.getRecordVariables(record);
if (variablesHtml) {
html.push(variablesHtml);
html.push('<br>');
}
======================
getRecordVariables: function(record) {
var varHtml = [];
var tableName = record.getTableName();
var recordSysId = record.getUniqueValue();
try {
if (tableName === 'sc_req_item') {
varHtml = this._getVariablesFromQuestionSet(recordSysId);
return varHtml.join('');
}
else {
varHtml = this._getVariablesFromQuestionAnswer(tableName, recordSysId);
return varHtml.join('');
}
} catch (error) {
gs.error('acelenNotificationUtils.getRecordVariables() Error: ' + error);
return '';
}
},
=========================================================
_getVariablesFromQuestionAnswer: function(tableName, recordSysId) {
var varHtml = [];
try {
var qaRecord = new GlideRecord('question_answer');
qaRecord.addQuery('table_name', tableName);
qaRecord.addQuery('table_sys_id', recordSysId);
qaRecord.addQuery('question.type', '!=', 'multi_row_variable_set');
qaRecord.orderBy('order');
qaRecord.query();
while (qaRecord.next()) {
var label =
qaRecord.question.getDisplayValue('label') || qaRecord.question.getDisplayValue('question_text');
var value = qaRecord.value.getDisplayValue();
if (label && value && value !== 'false' && value !== '' && value !== 'null') {
varHtml.push('<b>' + label + ':</b> ' + value + '<br>');
}
}
} catch (error) {
gs.error('acelenNotificationUtils._getVariablesFromQuestionAnswer() Error: ' + error);
}
return varHtml;
},
0 REPLIES 0
