HyperLInk in field label

tushar_ghadage
Tera Contributor

Hi All, 

I have having one req where I want to add a choice field 

"Has the demand been reviewed and is it in-line with tech standards and architecture principal?

where " tech standards" & "architecture principal" are hyperlink in the field display name itself.

 

Not able to figure out how to do it using annotation ...?

Can anyone suggest me how to do it ...?

 

Anything would help!!

thanks!!

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

This is the only way I've gotten something similar to work - a field message with links

BradBowman_0-1766060204441.png

An onLoad Client Script ensuring Isolate script is unchecked after the record is created:

function onLoad() {
	// Show Field message with an embedded hypertext link.
	var str = "";
	var placeholder = "##placeholder##";
	g_form.showFieldMsg('u_due_date_term', placeholder, 'info', false); //field name
	str = this.document.getElementsByClassName("fieldmsg notification notification-info")[0].innerHTML;
	str = str.substring (0, str.indexOf(placeholder));
	this.document.getElementsByClassName('fieldmsg notification notification-info')[0].innerHTML = str + "Please <a href='http://www.ibm.com' target = '_blank'>Click here</a> for more information."; //links and text
}

 

M Iftikhar
Tera Sage

Hi @tushar_ghadage 

I agree with @Brad Bowman , this works using a client script.

You can implement it by going to System Definition → Client Scripts and creating a new onLoad client script. Fill in the fields as shown in the screenshot.

MIftikhar_0-1766072245756.png

Paste the script below:

function onLoad() {

  // placeholder text
  var placeholder = "This is testing for community";

  // show a temporary field message
  g_form.showFieldMsg(
    'u_string_3', // field name
    placeholder,
    'info',
    false
  );

  // get the field message container
  var msgElem = document.getElementsByClassName(
    "fieldmsg notification notification-info"
  )[0];

  // remove placeholder and inject link
  msgElem.innerHTML =
    "This is your <a href='https://facebook.com' target='_blank'>Facebook</a> Click here for more information.";
}

and make sure “Isolate Script” is unchecked, otherwise it may not work.

After saving, reload the form / table and you should see the blue info message with the clickable link below the field.

 

If my response helped, please mark it as the accepted solution so others can benefit as well.

 

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

Ankur Bawiskar
Tera Patron
Tera Patron

@tushar_ghadage 

field label only supports text.

Please inform customer about this OOTB limitation/feature

You can use DOM manipulation but it's not recommended practice

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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