How to give link in alert box using client script in service portal

Nisha28
Tera Contributor

Hello,

I have requirement if someone select incident from service portal and if the  escalation count on that  incident increase more than one then it should show a alert box that "incident is already escalated please click  here to know more about it ".

I have written a script include and calling that from client script to know the escalation count and showing that in alert it is coming correct but how to bring the link in it i am not getting .I have written the below code but it is taking complete text itself not coming as link.

var link1 = 'incident.do?sys_id='+newValue;
var link = '<a href = "'+ link1 +'"> </a>';
alert("Your Incident is already escalated and  If you want to know more ,please click" + link);
}

1 ACCEPTED SOLUTION

Hi,

update as this

var urlString = '<p><a class="web" target="_blank" href="' + "/incident.do?sys_id=" + newValue + '">' + "Click Here" + '</a></p>';

	g_form.addInfoMessage('Your Incident is already escalated  If you want to know more ,please click' + urlString);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Nisha,

You cannot using the alert()

You can use sweet alert

Anyone Successfully Using Sweetalert 2 with ServiceNow?

Try these links

1. Display URL link in the alert onChange

2. Please help me to display an Http:// url in the alert in client script

3. https://www.servicenowguru.com/system-ui/glidedialogwindow-advanced-popups-ui-pages/

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello Ankur,

Thanks for replying,

 

I tried the first option.

but by using location.herf it is remaining in the same page, i want it should go  to this "'incident.do?sys_id='+newValue;" 

How to achieve this 

 

 

Hi,

please share the script you are using and on which table the client script is written

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello Ankur,

 

on change Client script is written on catalog item.

var location = 'incident.do?sys_id='+newValue;

//var link = '<a href = "'+ link1 +'"> </a>';


g_form.addInfoMessage("Your Incident is already escalated  If you want to know more ,please click" + "<a href='"+location.href+"'>"+location.href+"</a>");
}