Plain and HTML Email generation and links

sherman_1206
Tera Contributor

Service Now emails we hare configured to be sent as plain text and HTML formatted text. The problem is that the plain text version does not include explicit URL when in the HTML version there is an anchor tag with an href defined to create the link.

Is there a way to resolve this issue and have plain text version of service now email messages generated to contain the URL along with the text the link would have in the plain text version of the email message?

5 REPLIES 5

sherman_1206
Tera Contributor

After further investigation it appears that if email is set to send as plain text only that the link will be included explicitly, whereas if the email is set to HTML & Plaintext than the html portion has the anchor tag with href included but the plaintext portion does not get the URL included explicitly.

Any comments on this?


You'll probably want to log an enhancement request for this issue. Until then, you could consider creating a business rule that runs before insert or update that looks at the 'Content type' field for a value of 'text/plain'. If that content type is found (indicating that a plaintext email should be sent), then your business rule would run and evaluate the string in the 'body' field (which is sent out for html email) to look for the 'href' attribute. If that is found, then you could take the url value from that attribute and populate that into the correct part of the 'body_text' field (which is sent out for plaintext emails).
I don't know of a quick way to write that script, but it can be done with some fancy javascript string parsing if you're up to it.


First off thanks for the comments, appreciate your feedback.

I cannot lie my experience with using the Service Now interface is very minimal. I come from the web and application programming domain and was brought into service now recently to implement SOAP interactions with service now. After becoming involved, I have been asked more and more questions regarding other items within service now (such as this one).

Additionally, I cannot fathom that the js implementation would be too tricky although my question is can I merely insert my own javascript code as I wish? The reason I ask is because I spent some time tinkering around with the Content manager at which point I deemed it not feature rich enough to use and decided to write my own Soap Client to interact with service now from our own servers. This solution has been more then optimal because of the fine grained control I have over the content and actions shown to the users. (Although it does take a bit of delving into the schema to find the relations you want for various items.) But back to the point, it took me a bit of effort to get my own JS running within the Content manager. To do this I was able to construct some dynamic content blocks, include my own library (I enjoy jQuery so this was my choice but any would work or raw javascript.) And then what I was able to do was insert this dynamic block onto Content manager pages and in other dynamic blocks within that page I was able to code some jquery/js to manipulate the page to do what I wanted to do with it that the content manager itself did not allow. (Cough cough, web accessibility!) The end result was Service now interface with few accessibility errors.

Since I am not familiar with the Service Now emailing aside from what a co-worker has shown me I wanted to know if I can merely insert my own javascript within the email templates and expect them to execute?

Thanks again,
Chris


This kind of sets you on a different path then what I responded with previously (although it might be better anyway).

You're probably going to have to do a little bit of reading (or ask one of the admins at your company) to get a better understanding of the scripting environment in Service-now. I mentioned a business rule on the 'sys_email' table in my previous post (you can access the 'sys_email' table by opening up the 'Email' system log).

Maybe a better solution would be to generate the link directly in the outgoing email message itself. You can run javascript in an email notification by enclosing your script in 'mail_script' tags as described here...
http://wiki.service-now.com/index.php?title=Scripting_for_Email_Notifications

A specific example of this is shown here...
http://www.servicenowguru.com/system-definition/email-links-uri-uriref/

I may still investigate a script for the business rule solution if I get time since it would allow you to set a single script globally instead of having to set up your script for each email notification, but the links above should get you going on a workable option for now.