Is it possible to redirect KB articles to an external link directly?

anurag92
Kilo Sage

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

1 ACCEPTED SOLUTION

larstange
Mega Sage

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;


      }


}


View solution in original post

16 REPLIES 16

oharel
Kilo Sage

Use this onLoad client script:



function onLoad() {


  //Type appropriate comment here, and begin script below


  if(g_form.getUniqueValue() == 'b5fbd36c37756200865bdb9643990e73') {//this is the sys_id of the article you want to redirect from


  var url = 'http://www.google.com';



  OpenWindow = window.open(url, '_blank');


  }


}


anurag92
Kilo Sage

Thank you guys. I appreciate all your suggestions. This worked fine when I opened it through a list view of KB articles.



What I couldn't get to work is, when an end user opens a Knowledge article from Knowledge homepage, this client script doesn't work. I believe there would be a catch here. Something needs to be done in Jelly UI Page for KB View. Please help me out here if my understanding is wrong.:



find_real_file.png


larstange
Mega Sage

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;


      }


}


Hi Lars,



Tried on my instance and it works.




Telmo


This worked nicely sir. Thank you for your time and insights.