Adding a URL link within an Alert for a UI Policy

matthew_hughes
Kilo Sage

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.

4 REPLIES 4

Gopi Naik1
Kilo Sage

Hi @matthew_hughes ,

 

Open the article KB0074291 and click "view article" related link and use that URL in your code.

 

 

Hemant Goldar
Mega Sage

Sandeep Rajput
Tera Patron

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

Ankur Bawiskar
Tera Patron

@matthew_hughes 

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.