Adding a link in error box message

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2016 10:27 AM
Hi ,
Currently i have a error box message in my client script .
g_form.showErrorBox('*******', "****************************http://***********.");
The above line shows how i have it currently , I would like to have it as
g_form.showErrorBox('*******', "****************************LINK.");
I would like to add a url link to that message, How can i do that???
Your help is much appreciated.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2016 10:37 AM
Try this
addInfoMessage(message) | Displays an informational message for the current session with a blue information icon and a light-blue background. Can also include HTML in the message! Note that I've replaced the greater than and less than symbols with brackets in the HTML usage example to get it to display correctly here. You'll need to change the brackets back to standard HTML to get it to work in your instance. | gs.addInfoMessage('Session Info Message Text'); //Info message with HTML formatting //Create the html contents of the information message var link = '[a href="incident.do?sys_id=' + current.sys_id + '" class="breadcrumb" ]' + current.number + '[/a]'; var message = 'Incident ' + link + ' has been created. '; message += 'Thank you for your submission.'; //Add the information message gs.addInfoMessage(message); |
Read more here
UI Info and Error Message Cheat Sheet - ServiceNow Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2019 05:14 AM
Hi Anurag,
I tried the solution you provided but it did not work for me. So I did the following and it worked like a charm.
var link = '<a href="incident.do?sys_id=' + current.sys_id + '" class="breadcrumb" >' + current.number + '</a> ';
link+='<img src="call.png" width="25" height="41" style="display:inline;"/>';
var message = 'Incident ' + link + ' has been created. ';
message += 'Thank you for your submission.';
gs.addInfoMessage(message);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2020 07:55 PM
I had the same issue and I found a way to use the function. I know this is already an old post, but it is still working (tested in Orlando) and maybe help other ones:
if (!answer.result) {
var linkText = "link text";
var msg = "Example msg ";
var htmlMsg;
if (answer.link) {
htmlMsg = msg + '<a href="' + answer.link + '" target="_blank">' + linkText + '</a>.';
}
msg += linkText + ".";
g_form.showErrorBox('fieldname', msg);
if (htmlMsg) {
try {
var control = g_form.getControl('fieldname');
//console.log(control.parentNode.lastElementChild.firstChild);
control.parentNode.lastElementChild.firstChild.innerHTML = htmlMsg;
} catch (error) {
// Ignore
}
}
}
This solution might not work, if you have multiple error messages below the field (will replace maybe text of the wrong error message). But as a quick solution it will do the job:
Not tested, if this will also work in the service portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2022 08:54 PM
This solution still works with the new UI in San Diego. I just tested it. 😉