knowledge articles UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2025 06:43 AM
Hi Team, can anyone help me please
I have created a custom UI action on knowledge table. I required to give the kb number in URL path. But here always picking the expired article.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2025 11:47 PM
try this
function onClick(g_form) {
var sys_id = g_form.getUniqueValue();
var instance = "https://" + parent.location.hostname + '/now/workspace/hr/record/kb_knowledge';
// Create a GlideRecord to check the state of the knowledge article
var gr = new GlideRecord('kb_knowledge');
if (gr.get(sys_id)) {
if (gr.getValue('workflow_state') !== 'retired') { // Check if the article is not expired
var knowLink = instance + '/' + sys_id;
parent.navigator.clipboard.writeText(knowLink).then(function() {
/* clipboard successfully set */
alert("Copied to clipboard.");
}, function() {
/* clipboard write failed */
});
} else {
alert("The selected knowledge article is expired.");
}
} else {
alert("Knowledge article not found.");
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 12:39 AM
Hi @Ankur Bawiskar i need KB number instead of sys id.but here in workspace not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 01:59 AM
what debugging did you perform?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 02:48 AM
- @Ankur Bawiskar I have written this script as I required kb number instead of sys I'd.but it is getting the knowledge record not found.
- function CopyKnowWorkspace() {var number = g_form.getValue('number');var instance = "https://" + parent.location.hostname; // Get the instance hostnamevar knowLink = instance + "/now/sow/kb_view/kb_knowledge/" + number; // Construct the URLif (number) {// Copy the link to clipboardcopyToClipboard(knowLink);alert("Copied to clipboard: " + knowLink);} else {alert("Knowledge article number is not available. Unable to generate link.");}}