To Create hyperlink in Client scripts, showFieldMsg

sowmyarajaram
Tera Expert

Hi All,

I'm trying to create a link in onChange Client script. Any Help will be Appreciated.

This is the actual link : https://instance_name.service-now.com/ess/form.do?sysparm_document_key=sc_cat_item,6b25d2b90c9a3d008...

And Trying the below Script, but getting the error saying "JavaScript parse error at line (7) column (159) problem = missing ; before statement"

function onChange(control, oldValue, newValue, isLoading) {

  if (isLoading || newValue == '') {

  return;

  }

  var url = '<a href="instance_name.service-now.com/ess/form.do?sysparm_document_key=sc_cat_item,6b25d2b90c9a3d008febd07b4e7cce07" target="_blank">'+click here+'</a>';

  var access = g_form.getValue('access_level');

  if(access != 'E1 License' || access != 'E3 License'){

  g_form.showFieldMsg('access_level',url,'error');

  }

  else {

  g_form.hideFieldMsg('access_level', true);

  }

}

Thanks,

Sowmya

3 REPLIES 3

Mike Allen
Mega Sage

var url = '<a href="instance_name.service-now.com/ess/form.do?sysparm_document_key=sc_cat_item,6b25d2b90c9a3d008febd07b4e7cce07" target="_blank">'+click here+'</a>';



So, you have a '+ click me +'.. not sure what you are trying to do here.   Give the name of the Link?   That is a variable call, with the pluses.   I would try this:



var url = '<a href="instance_name.service-now.com/ess/form.do?sysparm_document_key=sc_cat_item,6b25d2b90c9a3d008febd07b4e7cce07" target="_blank">Click here</a>';


Mike Allen
Mega Sage

Apparently, hyperlinks are not supported.   You should chec out Mark's suggestion here: Generate link in client script gs.showFieldMsg


VaranAwesomenow
Mega Sage

You need to get a little creative to make it work.

1. On the platform UI  UI macro works.. so use that to show the html text

2. On the service portal macros wont render but instructions field on the catalog variable will work so use that.

Basically a variable of type - Macro with Label which has the macro and instructions on it will work perfectly in both platform UI and service portal.

 screenshot for service portal

 

 

find_real_file.png

 

screenshot from platform UI

find_real_file.png

 

Variable screenshots

 

 

macro screenshot

 

find_real_file.png

 

find_real_file.png