Manage Learn to apply best practices and optimize your operations.

How to save agent output in a Web-based application

In my CRM application I wanted users to use client information in other applications, where they must be able to download specific information from the database.

In my CRM application I wanted users to use client information in other applications, where they must be able to download specific information from the database, such as e-mail addresses. Here's how I did it.

Create a form with a embedded view for the web
($$ViewTemplate for &ltviewname>)
with a field called $$SelectDoc (hidden for Web)
and a field SaveOptions with value "0" 
to prevent saving of the document.

On the associated view-properties under the 
advanced tab 'Allow selection of documents
' has to be checked.

WebQuerySave event calls the agent.

What happens is that the File Download box appears.
When you select Open, a text file 
opens with all e-mail addresses of the selected documents.

The trick is the lines
Print ("Content-type: application/txt");
Print ("Content-Disposition: attachment; filename=test.txt");

These send HTTP-Header information. 
  Code: code for action on actionbar on view:
var cb = document.forms[0].$$SelectDoc;
//find the first checked document ..
var selectcount = 0;
var docUNID = new Array();
for (i = 0; i < cb.length; i++) {
     if (cb[i].checked) {
          docUNID[selectcount] = cb[i].value;
if  (docUNID[0] == null) {
  alert('No documents selected.');
  if (docUNID != null){
         result = window.confirm('Emailaddresses
 are exported. Select OK to confirm');
         if (result == true){

The submit statement triggers the WebQuerySave event.

agent (webGetEmailaAddresses):

Sub Initialize
Dim ses As New notessession
Dim db As notesdatabase 
Dim doc, newDoc As notesdocument
Dim item As notesitem
Dim dateTime As New  
Set db=ses.currentdatabase
Set doc = ses.DocumentContext
Set item = doc.getFirstItem("$$SelectDoc")
Print ("Content-type: application/txt");
 Print ("Content-Disposition: attachment; filename=test.txt");
'for every value $$SelectDoc
 get the notes-document Forall v In 
item.Values Set newDoc = 
'send the emailadress to the
 browser Print  newDoc.Email(0) & Chr(13)
End Forall
End Sub

Do you have comments on this tip? Let us know.

This tip was submitted to the tip exchange by member W Bergkamp. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

Dig Deeper on LotusScript

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...