Sending a clickable link with the Email Navigation Add-on link

jmuomini
Mega Expert

Hi,

I'm trying to customize an email client template for kb_knowledge to send a clickable link with the Email navigation link from kb_home. I've tried ${URI} and ${URI_REF}, but these put in long, ugly URLs that aren't clickable. I've also added a URL calculation field to my kb_knowledge form, but when I put this field on my template with


<a href="${u_url}" target="_blank">${number}</a>

the emailed link is truncated to:


<a href="/kb_view.do?sysparm_article=KB10090" target="_blank">KB10090</a>.

If I then add the missing part of the URL:


<a href="https://usfdev.service-now${u_url}" target="_blank">${number}</a>


I end up with duplication:


<a href="https://usfdev.service-nowhttps//usfdev.service-now.com/kb_view.do?sysparm_article=KB10090" target="_blank">KB10090</a>


Any suggestions on how to get a simple clickable link from a KB article in an email client template?

Thanks, Jim
1 ACCEPTED SOLUTION

jmuomini
Mega Expert

Thanks to some deep digging by Sam Polk at the SNOW Help Desk with an assist from Cesar Sandoval, I have an answer at last to why my email URLs were being truncated and none on the rest of you were seeing this.

About a year ago I followed a tip to change the body field type on sys_email from String to HTML. This allows you to use the TinyMCE HTML editor in the email client. The unintended consequence is that full URLs links are changed to relative URL links during the process of changing the sys_email body text from plain text to HTML, according to Sam.

Thanks to Sam, Cesar and all who tried to help me.

Jim


View solution in original post

25 REPLIES 25

We looked at the link before sending and it looks fine. But when it is sent out the instance information is removed and it picks up at /kb_view.do... Curious.

Jim


jmuomini
Mega Expert

Hi Mark,

I didn't have a glide.servlet.uri property, so I added one. I also added the URL to glide.email.override.url. I don't have the null anymore and the URL looks fine before I send it, but after it goes out, it gets shortened.

I also have a ticket open with the help desk, but so far the tech hasn't been able to figure it out either.

Thanks for your help.

Jim


phillip_keigley
Kilo Contributor

I suspected glide.servlet.uri wasn't set but I wasn't sure. Email override will work also I think.

If you try this code again, with that property, it should work. Works for me. If that doesn't work; can you tell me what it gets shortened to?



<mail_script>
template.print('<a href="' + gs.getProperty("glide.servlet.uri") + 'kb_view.do?sys_kb_id=' + '$current.number">KB Article</a>');
</mail_script>


Phillip,

Before I send I have this: https://usf.service-now.com/kb_view.do?sys_kb_id=KB10147

What I end up with in my Inbox when I look at the source is this: KB Article

In Thunderbird it is a link but not clickable. Gmail lets me click on it, but I get a bad link error.

Thanks, Jim


jim pisello
Giga Expert

We also use SSO (SAML2.0). In our mail client template for KB articles we use the following mail script:





_____________________________________
Click here to view the Article:
<mail_script>
dothis();
function dothis() {
var servletUri = gs.getProperty('glide.servlet.uri');
template.print(servletUri + 'nav_to.do?uri=kb_view.do?sysparm_article=' + current.number + '\n');
}
</mail_script>


In addition we modified our kb_view UI Page with a client script to allow emailing a link to the KB article right from the UI Page. Paste the following code into the Client Script field on the UI Page record:


function emailArticle() {
var i = document.getElementById("kb_sys_id");
var id = i.value;
popupOpenEmailClient("email_client.do?sysparm_target=kb_knowledge&sysparm_table=kb_knowledge&sysparm_sys_id=" + id + "&sys_uniqueValue=" + id);
}


In order to take advantage of this you'll need to add the email icon to the kb_view page. We added another cell to the table in the page header:


<!-- Anchor tag added to insert an the email icon START-->
<td>
<a href="javascript:emailArticle();"><img name="not_important" title="Share this Article in email" src="images/icons/email.gifx" border="0" /></a>
</td>
<!-- Anchor tag added to insert an the email icon END -->


Note that modifying your UI Page precludes it from being updated by future SN releases, patches, hot fixes, etc. You might want to make a copy of the kb_view UI Page and modify that, then reference the custom page in scripts, etc.