I have a strange issue occurring with generating URLs to attachments stored on a notes document.
The Xpage that displays the notes document has a repeat that retrieves the embedded objects from the body field with this code:
var doc:NotesDocument = docEmail.getDocument();
if (doc.hasEmbedded()){
var rtItem:NotesRichTextItem = doc.getFirstItem("Body");
return rtItem.getEmbeddedObjects()
}
I then have a hidden input field that stores the URL generated by this code (colBodyAttachments is the repeat collection name):
var doc:NotesDocument = docEmail.getDocument();
var dbComms = doc.getParentDatabase();
var dbServer = ReturnSvrHostName(dbComms.getServer())
var dbPath = @ReplaceSubstring(dbComms.getFilePath(), '\\', '/');
var attachmentName = colBodyAttachments.getName()
return "http://" + dbServer + "/" + dbPath + "/0/" + doc.getUniversalID() + "/$FILE/" + attachmentName
That works fine on 99.9% of the docs however it doesn't seem to generate the URL correctly when I have attachments with a name like this: "120531.Whytes Invoice # 701537.pdf"
The URL that is produced looks like this:
http://website.com/database.nsf/0/ABA667304AB04454CC257A4F0015D321/$FILE/120531.Whytes%20Invoice%20# 701537.pdf
It doesn't encode the %20 after the # and even if I try to do that I still get an 'Item Not Found Exception'. Is there issues encoding a url when a hash is present? Or with domino finding the attachment when a hash is present?