How to add a link on an error message

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2016 09:27 AM
Hello all,
I am trying to add a link to an field error message. This is what I have so far but it is not working, it keeps giving me the actual URL instead of turning it into a link. Would you be able to point me in the right direction on how to get the link working? Any help is appreciated!
This is the script:
var chainOfCust = g_form.getValue('u_chain_of_custody');
if (chainOfCust != true) {
var link = '[a href="https://gendev.service-now.com/kb_view.do?sysparm_article=KB0000054"'+ '[/a]';
g_form.setMandatory('u_chain_of_custody', true);
g_form.showFieldMsg('u_chain_of_custody', 'The checkbox must be checked when closing the task to ensure that a Chain of Custody form is included with the Hard Drive. To download the form, please click the link' + link, 'error');
}
and this is what it looks like:
Thank you for your help,
Yeny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2016 08:48 AM
Yeny,
I'm not 100% sure if links are allowed in field messages. I have tried your code with placing [code]<link html>[/code] tags around the html code. I know this will work in work notes if you have "Allow support for embedding HTML code by using the [code] tag " true under high security properties.
I did find a old post with a DOM trick, but again DOM is not recommend. Generate link in client script gs.showFieldMsg Look at what Mark shared.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2016 01:16 PM
Hi Patrick,
Thank you very much for your suggestion! This helps for the future. What I ended up doing for this particular case was using the URL option in the field. I went to 'personalize label' in the field and there is an option there to add a URL. I added the URL and the field itself became the link. I wasn't aware of that option until after doing some searching yesterday. It helped with what I needed to get done. Your suggestion is greatly appreciated and i will be trying it out on another request that I have pending.
Thank you so much!
Yeny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2016 10:07 AM
There is a way I believe to do a redirect after they hit ok on the error message. i dont have the exact code but its something like this
if(confirm("You will be directed to the page you need to use.")){
// var ai = getAISysId();
location.href = "URL";

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2016 02:24 PM
Hi Bessam,
Thank you for your suggestion. My customer would like to not be re-routed to a different page, what they want is to be able to have the link on the form. Preferably when the error message appears. I would like to add the link to the document to the gs.addErrorMsg part. I'm just not sure how to do that...
Thank you,
Yeny