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

Allen Andreas
Administrator
Administrator

Hi,

In a client script message where? Like in an info message (blue message at top of page)?

Here, you're setting a field value to some string?

Please mark reply as Helpful, if applicable. Thanks!


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

I have it in the answer part of the script.  I tried to put the direct url in there

Hi @scottangehr 

Yes, I see that and understand the script, but that's not normally where a clickable message would show up if you're assigning it to a field. You'd do that in an infomessage as I mentioned above.

You also didn't have that second screenshot either, originally, which gives a bit more information to us, so thanks for posting that.

If my reply above helped ask probing questions to get more information from you, then please mark the reply as Helpful.

Unfortunately, it's not very clear what type of field that that is nor where you've seen it before where it is clickable. I've personally never seen a string field have a clickable element to it within a form.

Thanks!


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

Hey Allen

Thank you for the response.  I think you jumped on this before i meant to post when i accidentally published.

The field is a string field that reports off of an SLA for a countdown.  I have a reopen ui action, but the business owner would like to have a clickable hyperlink in the message provided.  If you believe that a hyperlink cannot be added to a string, I'll report that back to the BO.

I can't remember the case where I had seen this before, but thinking back, it might not had been in a string.

Here's more recent shot showing the timer is counting down.

find_real_file.png

Again, I appreciate your assistance.  Let me know if I can provide any more detail.

Regards,
Scott