Friday, 10 June 2011

How to email a doclink to an XPage document

Workflow applications are a common strength of Lotus Domino. This post explains how to send workflow emails from XPage applications.

There are two situations:
  1. Your document and XPage are in the same database;
  2. Your Xpages are in a different database to your documents.
1. In the first case you can still send doclinks, like you have always done. However, you do need to set a new property on the Notes Form to ensure that when the doclink is activated, it will render the document in the correct XPage:

Set the property 'Display XPage instead' to ensure doclinks do not open using the raw form.

2. The ability to separate the code from the data is a strength of XPages. But it is then no longer possible to set the property on a document's form when the XPage is not in the same database. We need to send a link using mime, as you would have done in earlier versions of Notes. Here is the SSJS version:

var body = memo.createMIMEEntity();
var stream = session.createStream();
var info = <see below>;
body.setContentFromText(stream, "text/html; charset=iso-8859-1", 0);

In this case we simply want the email recipient to see a message about their role in the workflow, followed by a hotlink (Open Link) to open the appropriate document:

var info = msg + "<br /><br /><a href='"+applicationScope.serverURL + "/apps/code.nsf/xProposal.xsp?databaseName="+applicationScope.serverCN+"!!"+ applicationScope.dataDbName+"&documentId="+ doc.getUniversalID()+"&action=openDocument &content= docs_form'>Open Link</a>";

Application scope variables define the url of the server where the XPage is located and another to define the common name of the server where the database that contains the document is located. You can see that the link is to the XPage, xProposal.xsp, with the parameter, databaseName, defining the server and database, then the documentId parameter defining the document's universal id. The action parameter determines whether to open in read mode or edit mode.

You do need to apply Fixpack 2 to your 8.5.2 Domino servers if you wish to store your XPages in a datatbase that is in a different directory to the databases containing your documents and then be able to access this from the Notes client.


  1. Medical Transcriptionist online training?

  2. Thats great. i chose got the right one information at the right time for the right situation. thanks for sharing.
    sculpsure in duarte california