Skip to content
38 changes: 38 additions & 0 deletions Moveworks messages html for Flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var article = fd_data._1__look_up_record.record;

// Safely retrieve fields with null checks for a KB Article
var sys_id = article.sys_id || '';
var articleTitle = article.short_description || 'N/A';
var requestedBy = fd_data.trigger.current.sys_created_by;
var articleNumber = article.number || 'N/A';
var requestedOn = article.sys_created_on || 'N/A';
var kbName = (article.kb_knowledge_base && article.kb_knowledge_base.title) || 'N/A';
var knowledgeManagers = (article.kb_knowledge_base && article.kb_knowledge_base.owner && article.kb_knowledge_base.owner.getDisplayValue()) || 'N/A';

// Base URL
var baseUrl = gs.getProperty('glide.servlet.uri') || '';
var kbLink = baseUrl + 'kb_knowledge.do?sys_id=' + sys_id;
//Below are links for opening the record in servicenow
var approveLink = baseUrl + 'sysapproval_approver.do?action=approve&sys_id=' + sys_id;
var rejectLink = baseUrl + 'sysapproval_approver.do?action=reject&sys_id=' + sys_id;
//Below lines are for email template which is used to create email inbound template.
var inst ='inspirebrandsdev';
var approveSub = 'RE: '+ articleNumber +' Approve KB Article ';
var body = 'Please do not change the subject, just click send message.';
var rejectSub = 'RE: '+ articleNumber +' Reject KB Article ';


// HTML message
var message =
'<b>Pending approval request from ServiceNow</b><br><br>' +
'<b><a href="' + kbLink + '">' + articleNumber + '</a>: ' + articleTitle + '</b><br><br>' +
'<b>Requested by:</b> ' + requestedBy + '<br>' +
'<b>Requested on:</b> ' + requestedOn + '<br>' +
'<b>Knowledge Base:</b> ' + kbName + '<br>' +
'<b>Knowledge Managers:</b> ' + knowledgeManagers + '<br><br>' +
'<b>Approve link :</b> <a href="mailto:' + inst + '@service-now.com?SUBJECT=' + approveSub + '&amp;body=' + body + '">Click here</a><br>'+
'<b>Reject link :</b> <a href="mailto:' + inst + '@service-now.com?SUBJECT=' + rejectSub + '&amp;body=' + body + '">Click here</a><br>';
//'<b>Approve link :</b> <a href="' + approveLink + '">Click here to approve</a><br>' +
//'<b>Reject link:</b> <a href="' + rejectLink + '">Click here to reject</a>';

return message;
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
📘 README — KB Article Link Email Script for Notification
✅ Overview

This script is used in a ServiceNow notification triggered from the kb_knowledge table.
It dynamically retrieves the instance URL and constructs a clickable Knowledge Article link in the email body.

🧩 Script Functionality
✔ What It Does

Builds a direct URL pointing to the KB article
Displays the KB Number as a clickable hyperlink
Opens the article in a new browser tab
Improves Knowledge Manager review workflow

🔧 Script Used
// This script assumes it is used in a notification triggered by the kb_knowledge table.
//use this line to get KB Number ${mail_script:get_kbarticle_link}
(function executeEmailScript(current, template) {
// Construct the URL to the KB article

var instanceURL = gs.getProperty('glide.servlet.uri'); // Get the instance URL
var kbLink = instanceURL + "kb_view.do?sysparm_article=" + current.number; // Adjust based on your URL structure

// Output the link in HTML format
template.print('<a href="' + kbLink + '" target="_blank">' + current.number + '</a>');
})(current, template);

📝 Notification Configuration
Setting Details
Table Knowledge [kb_knowledge]
Condition Example: State changes to Pending Approval
Email Script Used ${mail_script:get_kbarticle_link}
Audience Knowledge Managers / Approvers
📥 Input
Input Source Description
current.number KB Article Number (e.g. KB0012345)
System Property glide.servlet.uri — full instance URL
Notification Payload Uses script reference in message body

Example Input Values:

Instance URL: https://company.service-now.com/
KB Number: KB1029384

⚙️ Process Flow

1️⃣ Notification triggered on kb_knowledge
2️⃣ Script collects instance URL
3️⃣ Script forms hyperlink using KB Number
4️⃣ Link injected into template via template.print
5️⃣ Email delivered to recipients

✅ Output / Result

📌 Email will show a clickable KB Number link:
➡ Example Link Generated:
https://company.service-now.com/kb_view.do?sysparm_article=KB1029384


📌 In Email (HTML):
KB1029384 → Click → Opens article in new browser tab

📬 Final Email Result Includes:
KB Article Number (hyperlinked)
Article details (added in notification body)
Approve & Reject action buttons (if included)
Cleaner and faster approval workflow

🖼️ Visual Result (Explained from Shared Image)

<img width="733" height="446" alt="image" src="https://github.com/user-attachments/assets/675b3d9b-f121-4c79-8253-bcb964ae05b3" />


The screenshot you shared displays:
✅ KB Article Number hyperlink
✅ Metadata such as short description & requested by
✅ Buttons for Article Approval / Rejection
✅ HTML formatted clean layout for readability
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// This script assumes it is used in a notification triggered by the kb_knowledge table.
//use this line to get KB Number ${mail_script:get_kbarticle_link}
//NOTE THE NAME OF THIS SCRIPT IS "get_kbarticle_link"IN EMAIL SCRIPTS TABLE _ "sys_script_email"


(function executeEmailScript(current, template) {
// Construct the URL to the KB article

var instanceURL = gs.getProperty('glide.servlet.uri'); // Get the instance URL
var kbLink = instanceURL + "kb_view.do?sysparm_article=" + current.number; // Adjust based on your URL structure

// Output the link in HTML format
template.print('<a href="' + kbLink + '" target="_blank">' + current.number + '</a>');
})(current, template);
Loading