Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 06:05 AM
Here is code, currently it's not printing
var number = current.number;
var rejectNotes = "";
var short_desc = current.short_description;
var article_body = current.text;
var article_link = gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=kb_knowledge.do?sys_id=" + current.sys_id;
var author;
var revisor = current.revised_by;
if (revisor)
author = revisor.first_name;
else
author = current.author.first_name;
var approval = new GlideRecord("sysapproval_approver");
approval.addQuery("document_id", current.sys_id);
approval.addQuery("state", "rejected");
approval.query();
if (approval.next()) {
var approvalSysId = approval.sys_id;
}
var approval_link = gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=sysapproval_approver.do?sys_id=" + approvalSysId;
var emailContent = {};
emailContent.templateContent =
"<div style='font-size:10pt; font-family:verdana;'>" +
"Dear "+author+",<br/>" +
"<br/>" +
"Knowledge Article: " + number + " has been rejected for publication. Please review the Approver's comments, adjust the article and re-send it for approval.<br/>" +
"<br/>" +
"Click here to review the rejected request: <a href='" + approval_link + "'>rejected request</a><br/><br/>" +
"Short description: " + short_desc + "<br/>" +
"<br/>" +
"Article body: " + article_body + "<br/><br/>" +
"Click here to view the article: <a href='" + article_link + "'>View Article</a><br/><br/>" +
"<br/>" +
"Thank you."
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 06:19 AM
current.author might be a reference field, and you're trying to access first_name directly without ensuring it's a valid GlideRecord object.
var number = current.number;
var rejectNotes = "";
var short_desc = current.short_description;
var article_body = current.text;
var article_link = gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=kb_knowledge.do?sys_id=" + current.sys_id;
// Initialize author variable
var author = "Unknown Author";
// Retrieve the revisor (if available)
var revisor = current.revised_by;
if (revisor) {
var userRecord = new GlideRecord("sys_user");
if (userRecord.get(revisor)) {
author = userRecord.first_name;
}
} else if (current.author) {
var userRecord = new GlideRecord("sys_user");
if (userRecord.get(current.author)) {
author = userRecord.first_name;
}
}
// Retrieve approval link
var approval = new GlideRecord("sysapproval_approver");
approval.addQuery("document_id", current.sys_id);
approval.addQuery("state", "rejected");
approval.query();
var approval_link = "#"; // Default value
if (approval.next()) {
approval_link = gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=sysapproval_approver.do?sys_id=" + approval.sys_id;
}
// Construct email content
var emailContent = {};
emailContent.templateContent =
"<div style='font-size:10pt; font-family:verdana;'>" +
"Dear " + author + ",<br/>" +
"<br/>" +
"Knowledge Article: " + number + " has been rejected for publication. Please review the Approver's comments, adjust the article and re-send it for approval.<br/>" +
"<br/>" +
"Click here to review the rejected request: <a href='" + approval_link + "'>rejected request</a><br/><br/>" +
"Short description: " + short_desc + "<br/>" +
"<br/>" +
"Article body: " + article_body + "<br/><br/>" +
"Click here to view the article: <a href='" + article_link + "'>View Article</a><br/><br/>" +
"<br/>";
Please mark helpful/correct if this helps you
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 06:19 AM
current.author might be a reference field, and you're trying to access first_name directly without ensuring it's a valid GlideRecord object.
var number = current.number;
var rejectNotes = "";
var short_desc = current.short_description;
var article_body = current.text;
var article_link = gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=kb_knowledge.do?sys_id=" + current.sys_id;
// Initialize author variable
var author = "Unknown Author";
// Retrieve the revisor (if available)
var revisor = current.revised_by;
if (revisor) {
var userRecord = new GlideRecord("sys_user");
if (userRecord.get(revisor)) {
author = userRecord.first_name;
}
} else if (current.author) {
var userRecord = new GlideRecord("sys_user");
if (userRecord.get(current.author)) {
author = userRecord.first_name;
}
}
// Retrieve approval link
var approval = new GlideRecord("sysapproval_approver");
approval.addQuery("document_id", current.sys_id);
approval.addQuery("state", "rejected");
approval.query();
var approval_link = "#"; // Default value
if (approval.next()) {
approval_link = gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=sysapproval_approver.do?sys_id=" + approval.sys_id;
}
// Construct email content
var emailContent = {};
emailContent.templateContent =
"<div style='font-size:10pt; font-family:verdana;'>" +
"Dear " + author + ",<br/>" +
"<br/>" +
"Knowledge Article: " + number + " has been rejected for publication. Please review the Approver's comments, adjust the article and re-send it for approval.<br/>" +
"<br/>" +
"Click here to review the rejected request: <a href='" + approval_link + "'>rejected request</a><br/><br/>" +
"Short description: " + short_desc + "<br/>" +
"<br/>" +
"Article body: " + article_body + "<br/><br/>" +
"Click here to view the article: <a href='" + article_link + "'>View Article</a><br/><br/>" +
"<br/>";
Please mark helpful/correct if this helps you