Adding a URL link within an Alert for a UI Policy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 04:40 AM
I've got a catalogue item where an alert message appears when certain options are selected. I've created a UI Policy for this and applied the following code:
function onCondition() {
var link ='<a href="https//lbg.service-now.com/kb_view.do?sysparm_article=KB0074291" target="_blank">KB0074291</a>';
alert("The combination for RHS Category/RHS Sub - Category you have selected does not align with the selected Strategic Status. Please review your selection for strategic status and RHS. See Toxic Combinations List in " + link + " for conflicting RHS and Strategic Status combinations.");
}
I'm wanting the alert to show KB0074291 as the link and to open in a new windows. But what it's doing is showing all of html text within the alert. I was just wondering why this is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 04:48 AM
Hi @matthew_hughes ,
Open the article KB0074291 and click "view article" related link and use that URL in your code.
Thanks,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 04:49 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 04:52 AM
Unfortunately alert() is a method of the window object that cannot interpret HTML tags. You can choose to use addInfoMessage or addErrorMessage instead.
Source: https://stackoverflow.com/questions/5278197/html-tags-in-javascript-alert-method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 04:54 AM
alert won't support html tags so it won't work.
Please use info message for this and not alert
function onCondition() {
var link ='<a href="https//lbg.service-now.com/kb_view.do?sysparm_article=KB0074291" target="_blank">KB0074291</a>';
g_form.addInfoMessage("The combination for RHS Category/RHS Sub - Category you have selected does not align with the selected Strategic Status. Please review your selection for strategic status and RHS. See Toxic Combinations List in " + link + " for conflicting RHS and Strategic Status combinations.");
}
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