How to insert the link for message

Junyu
Tera Contributor

Dear all,

 

I have a question is it possible for us to insert the link for the message(sys_ui_message.list)? How to do that?

Junyu_0-1696837883978.png

 

1 ACCEPTED SOLUTION

Hi @Junyu,

Here's is an example:

 

function onSubmit() {
   
   var shortDescrp = g_form.getValue("short_description");
   var descrp = g_form.getValue("description");
   var uri = '<a href="./esc?id=sc_cat_item&sys_id=---sys_idhere---">Catalog item name</a>';

   if(shortDescrp == "" || descrp == "")
   {
	g_form.addErrorMessage(getMessage('Error Message iSource Support',uri));
	return false;
   }
   
}

 

Your message record would then look like:

 

You can create a ticket by going to {0}


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

View solution in original post

4 REPLIES 4

Peter Bodelier
Giga Sage

Hi @Junyu,

 

Take a look at GlideSystem | ServiceNow Developers.

 

You can use parematers in the message which are set in the text as {0], {1}, etc.

This means that you can parse a url or name as parameter to show this dynamically.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Hi @Peter Bodelier ,

 

Thanks for your answer, but can you show me a case of how to let the catalog link as a link in this client script?

function onSubmit() {
   
   var shortDescrp = g_form.getValue("short_description");
   var descrp = g_form.getValue("description");

   if(shortDescrp == "" || descrp == "")
   {
	g_form.addErrorMessage(getMessage('Error Message iSource Support'));
	return false;
   }
   
}

 

Junyu_0-1696839033181.png

 

Hi @Junyu,

Here's is an example:

 

function onSubmit() {
   
   var shortDescrp = g_form.getValue("short_description");
   var descrp = g_form.getValue("description");
   var uri = '<a href="./esc?id=sc_cat_item&sys_id=---sys_idhere---">Catalog item name</a>';

   if(shortDescrp == "" || descrp == "")
   {
	g_form.addErrorMessage(getMessage('Error Message iSource Support',uri));
	return false;
   }
   
}

 

Your message record would then look like:

 

You can create a ticket by going to {0}


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

thank you for your sample code.
Just for one point , below code didn't work in my environment,

g_form.addErrorMessage(getMessage('Error Message iSource Support',uri));

after changing ',' to '+', it works!

g_form.addErrorMessage(getMessage('Error Message iSource Support'+uri));