|
| 1 | +📘 README — KB Article Link Email Script for Notification |
| 2 | +✅ Overview |
| 3 | + |
| 4 | +This script is used in a ServiceNow notification triggered from the kb_knowledge table. |
| 5 | +It dynamically retrieves the instance URL and constructs a clickable Knowledge Article link in the email body. |
| 6 | + |
| 7 | +🧩 Script Functionality |
| 8 | +✔ What It Does |
| 9 | + |
| 10 | +Builds a direct URL pointing to the KB article |
| 11 | +Displays the KB Number as a clickable hyperlink |
| 12 | +Opens the article in a new browser tab |
| 13 | +Improves Knowledge Manager review workflow |
| 14 | + |
| 15 | +🔧 Script Used |
| 16 | +// This script assumes it is used in a notification triggered by the kb_knowledge table. |
| 17 | +//use this line to get KB Number ${mail_script:get_kbarticle_link} |
| 18 | +(function executeEmailScript(current, template) { |
| 19 | + // Construct the URL to the KB article |
| 20 | + |
| 21 | + var instanceURL = gs.getProperty('glide.servlet.uri'); // Get the instance URL |
| 22 | + var kbLink = instanceURL + "kb_view.do?sysparm_article=" + current.number; // Adjust based on your URL structure |
| 23 | + |
| 24 | + // Output the link in HTML format |
| 25 | + template.print('<a href="' + kbLink + '" target="_blank">' + current.number + '</a>'); |
| 26 | +})(current, template); |
| 27 | + |
| 28 | +📝 Notification Configuration |
| 29 | +Setting Details |
| 30 | +Table Knowledge [kb_knowledge] |
| 31 | +Condition Example: State changes to Pending Approval |
| 32 | +Email Script Used ${mail_script:get_kbarticle_link} |
| 33 | +Audience Knowledge Managers / Approvers |
| 34 | +📥 Input |
| 35 | +Input Source Description |
| 36 | +current.number KB Article Number (e.g. KB0012345) |
| 37 | +System Property glide.servlet.uri — full instance URL |
| 38 | +Notification Payload Uses script reference in message body |
| 39 | + |
| 40 | +Example Input Values: |
| 41 | + |
| 42 | +Instance URL: https://company.service-now.com/ |
| 43 | +KB Number: KB1029384 |
| 44 | + |
| 45 | +⚙️ Process Flow |
| 46 | + |
| 47 | +1️⃣ Notification triggered on kb_knowledge |
| 48 | +2️⃣ Script collects instance URL |
| 49 | +3️⃣ Script forms hyperlink using KB Number |
| 50 | +4️⃣ Link injected into template via template.print |
| 51 | +5️⃣ Email delivered to recipients |
| 52 | + |
| 53 | +✅ Output / Result |
| 54 | + |
| 55 | +📌 Email will show a clickable KB Number link: |
| 56 | +➡ Example Link Generated: |
| 57 | +https://company.service-now.com/kb_view.do?sysparm_article=KB1029384 |
| 58 | + |
| 59 | + |
| 60 | +📌 In Email (HTML): |
| 61 | +KB1029384 → Click → Opens article in new browser tab |
| 62 | + |
| 63 | +📬 Final Email Result Includes: |
| 64 | +KB Article Number (hyperlinked) |
| 65 | +Article details (added in notification body) |
| 66 | +Approve & Reject action buttons (if included) |
| 67 | +Cleaner and faster approval workflow |
| 68 | + |
| 69 | +🖼️ Visual Result (Explained from Shared Image) |
| 70 | + |
| 71 | +<img width="733" height="446" alt="image" src="https://github.com/user-attachments/assets/675b3d9b-f121-4c79-8253-bcb964ae05b3" /> |
| 72 | + |
| 73 | + |
| 74 | +The screenshot you shared displays: |
| 75 | +✅ KB Article Number hyperlink |
| 76 | +✅ Metadata such as short description & requested by |
| 77 | +✅ Buttons for Article Approval / Rejection |
| 78 | +✅ HTML formatted clean layout for readability |
0 commit comments