The CreatorCon Call for Content is officially open! Get started here.

Add hyperlink to Client Script message

scottangehr
Giga Guru

Odd request - I need to add a "Click here" option in a client script message to replace a UI Action.
I'm been trying to mess around with it and I know its possible, because I've seen it before.

Script sample

if (distance < 0) {
			clearInterval(x);
			answer = 'This incident is permanently closed!';
			g_form.setValue('u_timer',answer);
			gel('incident.u_timer').style.backgroundColor = "tomato";
			g_form.setReadOnly('u_timer', true);
			return ;
		} else {
			answer = 'You have '+days+'d '+hours+'h '+minutes+'m '+seconds+'s left to Reopen this Incident. Click <a href="https://<instance name>.service-now.com/nav_to.do?uri=incident.do?sys_id=eaf12dc51bdfc910c3c96535604bcbeb"> here</a>. to reopen this incident';
			g_form.setValue('u_timer',answer);
			gel('incident.u_timer').style.backgroundColor = "gold";
			g_form.setReadOnly('u_timer', true);
			return ;

 

 

I want it to do something like this with a clickable link

find_real_file.png

1 ACCEPTED SOLUTION

Hi,

Ah, ok, perhaps.

You're definitely not able to create a clickable URL within a string field.

You could try and use a URL field that it's link goes to the incident, but the verbiage says all that (like in your screenshot), but then the whole thing is clickable and may look a bit wonky.

You're better off using a form info message, for example, that is presented at the top of the form that can say all of that and then contain a clickable piece of it within.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

6 REPLIES 6

Hi,

Ah, ok, perhaps.

You're definitely not able to create a clickable URL within a string field.

You could try and use a URL field that it's link goes to the incident, but the verbiage says all that (like in your screenshot), but then the whole thing is clickable and may look a bit wonky.

You're better off using a form info message, for example, that is presented at the top of the form that can say all of that and then contain a clickable piece of it within.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Aman Kumar S
Kilo Patron

Hey,

Try doing something like this in your client script:

var link = '<a href="incident_list.do">List Link</a>';
var message = gs.getMessage('Incident Resolved') + ' ' + link + ' ';
gs.addInfoMessage(message);

 

Ref link

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0691931

Best Regards
Aman Kumar