Technical Blog Post
Abstract
Email Listener: Embedding Document Links in Free Form SR Long Description Proof of Concept
Body
If you want inbound free form communications with image attachments that create SRs with document links to allow the links to be embedded at the bottom of the request's long description field, then this automation script is for you!
Also, they should be displayed in message body of the corresponding commlog and inboundcomm record entries. This assumes the Rich Text Editor or Viewer is used in the applicable field (which is default configuration).
Launch Point
Launch Point: INBOUNDCOMMLP
LP Object: INBOUNDCOMM
Event: Save
Save: Add (Before Save)
Variables
Variable: BODY
Variable type: INOUT
Binding Type:ATTRIBUTE
Binding Value: MSGBODY
Script
Script: EMBED_SRC_TAGS
Script Language: jython
Source Code: (preserve formatting)
service.log("##### Let the fun begin #############################################")
from psdi.server import MXServer
from psdi.util import HTML
from psdi.util import LinkedDocumentInfo
docLinkSet = mbo.getMboSet("DOCLINKS")
text = ''
imgExts = ["jpg","gif"]
service.log("##### Include valid image formats that are already defined in mxe.doclink.doctypes.allowedFileExtensions: " + str(imgExts))
if not interactive:
if docLinkSet is not None and not docLinkSet.isEmpty():
text = "<br>Attachments:<br>\n"
docLink = docLinkSet.moveFirst()
while(docLink):
if docLink is not None:
docInfoSet = docLink.getMboSet("DOCINFO")
if docInfoSet is not None:
docInfo = docInfoSet.getMbo(0)
if docInfo is not None:
urlName = docInfo.getString("URLNAME")
service.log("#################################### urlName = " + urlName)
fileName = urlName[urlName.rfind("\\")+1:len(urlName)]
service.log("#################################### fileName = " + fileName)
fileExt = fileName[fileName.rfind(".")+1:len(fileName)]
service.log("#################################### fileExt = " + fileExt)
srcUrl = LinkedDocumentInfo.getDocumentURL(urlName)
service.log("We're only going to display image formats we want.")
if fileExt in imgExts:
text = text + "<img src=\""+srcUrl+"\"><br>"
docLink = docLinkSet.moveNext()
if text:
BODY = BODY + text.encode('utf-8')
BODY = BODY + HTML.RICH_TEXT_MARKER
service.log("#### Whew, we made it! #############################################")
Incoming Email
Resulting Ticket Body
UID
ibm11129203