Show hyperlink in info message

Sandy7
Tera Expert

Hello, 

on a catalog item i have an onChange catalog client script that is showing a message below a variable based on the variable selected from the select box. 

 

I am trying to add a hyper link to an external website in this message - 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    //Type appropriate comment here, and begin script below
    if (newValue == 1)
		{
       g_form.showFieldMsg('privilege_id_password_rotation_options', '3/6/9 days password rotation on Checkout Expiration. Please Reference: https://www.google.com', 'info');

I am looking to make https://www.google.com a link in this message. 
Is this possible? 

Thanks

 

 

4 REPLIES 4

Bhavya7
Tera Contributor

Musab Rasheed
Tera Sage
Tera Sage

Hello,

You can add this to addInfoMessage though both in client and server scripts, please have a look

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

https://www.servicenow.com/community/it-service-management-forum/add-link-in-info-message/m-p/836336

Please hit like and mark my response as correct if that helps
Regards,
Musab

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

We cannot show hyperlink message on showfieldmsg however we can do it in addinfo message, please use the below code:-

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    //Type appropriate comment here, and begin script below
    if (newValue == 1)
		{
    g_form.addInfoMessage("3/6/9 days password rotation on Checkout Expiration.  Please Reference:<a href = 'https://www.google.com''>https://www.google.com'</a>");
   }
}

 

Please mark my answer correct base on Impact.

snowycode
Tera Contributor

Hey @Sandy7  - we had a similar issue. I wrote out some code below that should do the trick for you.

 

Please note that it must be done in an addInfoMessage, since showFieldMsg won't allow hyperlinks.

 

 

// build the link and clickable text, set it equal to a variable
var link = '<a href="https://www.google.com" target="_blank">https://www.google.com</a>

// add the info message, using strings and the link variable that was built above
g_form.addInfoMessage('3/6/9 days password rotation on Checkout Expiration. Please Reference:  ' + link);

 

 

You can set a variable called 'link' equal to the hyperlink text, and then use it in your info message.

 

For an explanation on the code, you can see how we did it here.