Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

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

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

Thank you so much ankur it is working correctly

Glad to help.

Please remember to mark responses helpful as well

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

Hi @Ankur Bawiskar !

 

I do have similar kind of requirement.

If user select 'Yes' from the choice list, a popup will show with a link that says, Please raise a request to "XYZ Software".

 

I wrote a catalog client script:

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
   var yes = g_form.getValue('abc_application');
 
 if (yes) {
    var Url = 'link';
g_form.addInfoMessage("Please raise a request to 'xyz Software' in the catalog: <a href='" + Url + "'</a>");
}
}
 
The above code is not working. 
Kindly provide any solution.
 
TIA 
Hiranmayee Mohanta

@Hiranmayee Moha 

can you post a new question for this as this is an old thread? tag me there and share all the details.

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