- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2016 01:37 AM
Hello,
I have the following client script:
--------------------
function onChange(control, oldValue, newValue, isLoading) {
if (newValue == '')
return;
if (newValue == 'ABC')
g_form.addInfoMessage('Please see knowledge article KB0011111');
else
g_form.clearMessages();
----------------------
This script will add an info message at the top of the page when value is ABC. My question is, can I make the KB number as a hyperlink so that people could click on the KB number and be redirected to the its page?
Thanks,
Alex
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2016 02:20 AM
Hi Alexandru, Michal
It is possible to add the link in the addinfomessage. Please find the sample script below.
function onLoad() {
g_form.addInfoMessage("Please <a href = '/incident_list.do'>Click</a>");
}
Replace the above url with the one your looking to add.
Thanks
Abhishek
PS - Please mark this Helpful, Like, or Correct Answer if relevant.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2016 01:48 AM
Hello Alexandru,
Trough addInfoMessage i belive it is not possible.
I overcome this as appending the link to variable via scripting on the form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2016 01:55 AM
Hi Alexandru,
You can add a hyperlink in following manner in client side i.e Client Script
Query knowledge table and get the sys_id of the KB article and Knowlede Number
var sysId = //sys_id of the KB Article
var kbNumber = //KB article number
var knowledgeURL = 'https://yourInstanceName.service-now.com/kb_knowledge.do?sys_id='+sysId;
var urlString = '<p><a class="web" target="_blank" href="' + knowledgeUrl + '">' + kbNumber + '</a></p>';
g_form.addInfoMessage("Please see knowledge article "+urlString);
target = "_blank" will open the URL in new tab
target = "_self" will open the URL in same window
This will suffice. I had earlier used the same approach and it worked.
I hope this helps.
Please mark correct & helpful based on impact.
Regards
Ankur Bawiskar
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2016 02:07 AM
Ankur,
Thank you for your reply.
How do I combine your script with mine so that I can achieve what I need? I tried what you suggested and I'm getting some errors.
PS: I'm not very experienced with scripting.
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2016 04:52 AM
Hi Alexandru,
I just gave you a format for forming the URL.
You just need to replace the 2 variables i.e.
var sysId = //sys_id of the KB Article
var kbNumber = //KB article number
and also change the yourInstanceName to the instance you are using.
Rest all is same.
PS - Please mark it as Correct Answer if relevant.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader