Change KB article link generated by attach button

sarahmustakim
Kilo Contributor

Hi All,

If an Agent wants to add an KB article as a comment to an Incident, he can use the attach button at the "related (contextual) search results" section.

The "Attach" button creates a comment like this:

[code]<a title='Are Copyrighted Files Illegal to Have On My

Computer?' href='kb_view.do?sys_kb_id=1addc9f1474321009db4b5b08b9a7120' >KB0000009 : Are Copyrighted Files Illegal to Have On MyComputer?</a>[/code]

The url leads to the plain article without the frames.

I need to edit it to include the instance name like below:

https://<Instance Name>.service-now.com/nav_to.do?uri=/kb_view.do%3Fsys_kb_id%3D1addc9f1474321009db4b5b08b9a7120

Please assist.

Thanks,

Sarah

1 ACCEPTED SOLUTION

Gaurav Bajaj
Kilo Sage

HI Sarah,



There are two ways to achieve it but both comes with pros and cons.



1) Write a before update BR which check for the content going in the additional comments and modify it as per your need.


You can apply checks like the value contains kb_view.do and then make changes in the value before it gets saved.



This is a short and precise method which can act as a workaround.



2) The second one is that you update the   OOB script include (cxs_Knowledge) which creates this link.


     


find_real_file.png


You need to add the nav_to.do?uri= which will give your desired outcome.



Although to achieve this, you will have to remove the protection policy of the script include as its set to read-only and it won't let you edit anything.


Please run the below script in the background.



var gr = new GlideRecord("sys_metadata");  


gr.get("42ec6aa0ef62210066fc36caa5c0fbce");   // update the sys_id of script include cxs_Knowledge.


gs.print(gr.sys_policy);  


gr.sys_policy="";  


gs.print(gr.sys_policy);  


gr.update();



Disclaimer: This feature will come at expense of updating the OOB script include which will prevent it to get future updates, hence use if carefully if you want to manage the upgrades manually.




Thanks


Gaurav


View solution in original post

5 REPLIES 5

Thanks for the comment! I'm glad I was able to help.