- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 04:46 AM
Hi all,
I have got a requirement: KB article should directly link/point to an external URL.
Details:
When an end user clicks on a KB article in Knowledge base, he should be directly redirected to an external link rather than opening the KB article in ServiceNow.
I have provided an external link inside the article, so the end user can open the article and then click the link to re-direct. But the user does not want to open the article, but wants to go directly to external URL.
I know the requirement is a bit weird. Let me know if anyone has an experience with this.
P.S.: I have re-posted this, a bit desperate on understanding the possibility.
Regards,
Anurag
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 10:55 PM
Hi,
Yes you are correct. You need to make a client script in that ui page to open the link
It could look something like this (has not been tested)
//Get KB name on load and check if there is an external URL we must open
var KB = getParmVal('sysparm_article');
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('number',KB);
gr.query();
if (gr.next()) {
if (gr.externalLink != '')
window.open(gr.externalLink, '_blank');
}
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
else{
return;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 05:25 AM
If I understand the requirement correctly:
User is looking at the List View of kb articles and wants to click on a particular article and have it open where the link points to.
If that is correct, yes it is possible but in the list view the URL field cannot be the first column in the list view. Otherwise it would just open the kb article within ServiceNow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 05:27 AM
Hi
you could create your own url field in the kb_article table.
then add an onLoad client script which opens the the url whenever a KB article is displayed with content in the URL field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 05:39 AM
larstange 's suggestion is even better because you can re-use the same script for different articles, and add a condition that if the field is empty, don't do anything.
Let me know if you need help with the code,
Harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 05:48 AM
And if you decide to do it, here is the script to help you:
1. add a form to the field. Mine is u_external_link
2. onLoad:
function onLoad() {
//Type appropriate comment here, and begin script below
var externalLink = g_form.getValue('u_external_link');
if(externalLink == '') {
//do nothing
} else {
OpenWindow = window.open(externalLink, '_blank');
}
}
Note: make sure you give the full address in the, link, starting with http://
Harel