wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

Link to me: Notes Document Links as URL, Notes Link and Attachments


In the beginning the world was easy. You wanted to notify a user, just use @MailSend with [IncludeDocLink] and your email notification was done. It was obvious if your application was on a Notes client, your messaging application would be Notes as well.
Today the picture looks different. You might access your email through a portlet on the intranet or through a POP3 client. But you still want to be able to open that link in the Notes client right? I'm not aiming at web enablement here. What are your options:
  • In a Notes client you can use NotesRichText.AppendDocLink
  • You could send a link with notes:// ...
  • You can create an attachment as NDL file: To see what you need in there you copy a document link and paste it into Notepad. You will get this result:

    Wissel's Address Book - My Contacts
    <NDL>
    <REPLICA 4825713F:00352EEC>
    <VIEW OF85255E01:001356A8-ON852554C2:00753106>
    <NOTE OFE3DB4DB9:F46B6DAE-ON482572F9:00366DC6>
    <HINT>CN=d23m0120/OU=23/OU=M/O=IBM</HINT>
    <REM>Wissel's Address Book</REM>
    </NDL>

    Looks utterly familiar. Inside the NOTE the document uniqueID is embedded similar to the value in the property box. The stuff around the NotesDocument.UniversalID is static, so we can construct that. The view is the uniqueID of the design document. Luckily you can replace that with the name or alias of that view
Since all 3 cases are needed over and over again I added a little utility class to my script tools.The class gets initialized with the target document and provides methods that allow you to extract/attach a Notes document link, a Notes URL or an attached NDL file. Of course one could extend the class to generate the http URL as well (Be aware that this might not be that selfcontained anymore since you need to resolve http vs. https and the DNS name of the Domino server. Here is the class:
 
 
 
Public Class DocLinkHelper Private s As NotesSession Private db As NotesDatabase Private doc As NotesDocument Private v As NotesView Sub New (curDoc As NotesDocument ) Set doc = curDoc Set s = New NotesSession Set db = doc .ParentDatabase Set v = doc .ParentView End Sub Function NotesURL As String Dim vName As String If v Is Nothing Then vName = "/0/" Else If Isarray (v .Aliases ) Then vName = "/" + v .Aliases (0 ) + "/" Else vName = "/" + v . Name + "/" End If End If NotesURL = "notes://" +db .Server +vName +doc .UniversalID End Function Sub AppendLink (rt As NotesRichTextItem ) Call rt .AppendDocLink (doc ,doc .form (0 ) ) End Sub Sub AttachNotesLink (mailDoc As NotesDocument ) Dim out As NotesStream Dim linkFileName As String Dim rt As NotesRichTextItem Dim repID As String Dim viewID As String Dim noteID As String Dim unid As String linkFileName = "NotesLink-" +doc .UniversalID + ".ndl" Set out = s .CreateStream If Dir$ (linkFileName ) < > "" Then Kill linkFileName End If Call out . Open (linkFileName ) %REM The NDL Format looks like this: Wissel's Address Book - My Contacts <NDL> <REPLICA 4825713F:00352EEC> <VIEW OF85255E01:001356A8-ON852554C2:00753106> <NOTE OFE3DB4DB9:F46B6DAE-ON482572F9:00366DC6> <HINT>CN=d23m0120/OU=23/OU=M/O=IBM</HINT> <REM>Wissel's Address Book</REM> </NDL> %END REM repId = Left (db .ReplicaID ,8 ) + ":" + Right (db .ReplicaID ,8 ) If Isarray (v .Aliases ) Then viewID = v .Aliases (0 ) Else viewID = v . Name End If unid = doc .UniversalID noteID = "OF" + Left (unid ,8 ) noteID = noteID + ":" + Mid (unid ,9 ,8 ) noteID = noteID + "-ON" + Mid (unid ,17 ,8 ) noteID = noteID + ":" + Right (unid ,8 ) Call out .WriteText (db .Title + " - " + v . Name ,EOL_CRLF ) Call out .WriteText ( "<NDL>" ,EOL_CRLF ) Call out .WriteText ( "<REPLICA " +repID + ">" ,EOL_CRLF ) Call out .WriteText ( "<VIEW " +viewID + ">" ,EOL_CRLF ) Call out .WriteText ( "<NOTE " +noteID + ">" ,EOL_CRLF ) Call out .WriteText ( "<HINT>" +db .Server + "</HINT>" ,EOL_CRLF ) Call out .WriteText ( "<REM>" +db .Title + "</REM>" ,EOL_CRLF ) Call out .WriteText ( "</NDL>" ,EOL_CRLF ) Call out . Close If mailDoc .HasItem ( "Body" ) Then Set rt = mailDoc .GetFirstItem ( "Body" ) Else Set rt = New NotesRichTextItem (mailDoc , "Body" ) End If Call rt .EmbedObject ( EMBED_ATTACHMENT , "" ,linkFileName ) Kill linkFileName End Sub End Class
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.

Posted by on 26 November 2007 | Comments (5) | categories: Show-N-Tell Thursday

Comments

  1. posted by Keith Strickland on Wednesday 28 November 2007 AD:
    Cool, thanks for sharing.

    Keith
  2. posted by Slawek Rogulski on Wednesday 28 November 2007 AD:
    The little .NDL files are a way to link your ideas to (among others) a MindManager mind map. Although I think in a later version of either MM or Notes this linking has been improved.
  3. posted by Rich Bayless on Thursday 28 January 2010 AD:
    Stephan,

    While cool, I'm not sure what benefits there are in using such a complicated solution (compared to just dynamically building a "{ Link } Notes text link to the target DB/view/doc). The only advantage I could think of is that it would avoid the problem of long URL addresses getting split across multiple lines (and thereby breaking the "Notes text link").

    Might you be able to provide any additional benefits?

    Thanks so much,
    -Rich
  4. posted by Stephan H. Wissel on Thursday 28 January 2010 AD:
    @Rich: I like the links better than the NDL files too. There are however some use cases:
    a) the working style of the organization is file based. You can copy a NDL file into a directory, attach it to another eMail etc. a URL needs to be wrapped into a file first. To be clear: that is not my working style (I don't like files), but it is still quite common.

    b) a Notes URL only works if the registry key is properly set and all apps have been configured to deal with them. If you have sloppy installations (I know a lot of them - notes program dirs just copied over since it worked) users can't do anything. With a file you get that dialog, pick Notes one time, check the box: do that automatic and it works.
  5. posted by Rickard Varnfors on Thursday 17 December 2015 AD:
    Thanks for sharing! Great post! FYI I added the replica id to the NotesURL line. According to my tests this is needed (or the path/filename to the nsf)
    New code:
    .../"+db.Server+"/"+db.Replicaid+vName+doc.UniversalID