Thursday, May 29, 2008

Here you can download Lotus Notes / Domino

ftp://l0tus.com/Lotus/

I spend a lot of time for this. Now I found the good place for downloading Lotus Notes.

Tuesday, May 27, 2008

Saturday, May 24, 2008

Response document and field $RefOptions

Mostly if you would like to create new response document, we use method NotesDocument.MakeResponse. But if a document use "Document type" (I mean type which we set in Form properties), then after "UI" saving it will be not responsible document anymore.
But it is possible to fix it, all what we have to do is to set in field $RefOptions value "1"

NotesDocument.ReplaceItemValue("$RefOptions", "1")

Thursday, May 15, 2008

how to choose folder using lotus script + api

Sometimes we need to choose a folder during our process of development, but special function for this I did not found. Very often we need to choose only folder (for example for saving attaches from documents)

To solve this task we can use Win API 's methods. Here you will see an example of it.


(Declarations)

Const BIF_RETURNONLYFSDIRS = 1
Const BIF_DONTGOBELOWDOMAIN = 2
Const MAX_PATH = 260
Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As String
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Declare Function SHBrowseForFolder Lib "shell32" Alias "SHBrowseForFolderA" (lpbi As BrowseInfo ) As Long
Declare Function SHGetPathFromIDList Lib "shell32" Alias "SHGetPathFromIDListA" ( Byval pidList As Long, Byval lpBuffer As String ) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( Byval lpClassName As Any, Byval lpWindowName As Any ) As Long
Main functionFunction ChooseFolder ( dialogPrompt As String ) As String

Dim lpIDList As Long
Dim sBuffer As String * 255
Dim sReturnVal As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfo

sBuffer = String ( Len ( sBuffer ) , Chr(0) )
szTitle = dialogPrompt
tBrowseInfo.hWndOwner = FindWindow ( "notes", &H0 )
tBrowseInfo.lpszTitle = szTitle
tBrowseInfo.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
lpIDList = SHBrowseForFolder ( tBrowseInfo )

If ( lpIDList ) Then
SHGetPathFromIDList lpIDList, sBuffer
ChooseFolder = Left ( sBuffer, Instr ( sBuffer, Chr(0) ) - 1)
End If

End Function



Here is the code on button
Sub Click(Source As Button)
Dim w As New NotesUIWorkspace
Dim doc As NotesDocument
Dim folder As String

Set doc = w.CurrentDocument.Document

folder = ChooseFolder("Select directory")

If folder<>"" Then
Call doc.ReplaceItemValue("FolderPath", folder)
Call w.CurrentDocument.Refresh
End If

End Sub

Tuesday, May 13, 2008

how to run several Lotus Notes clients at the same time

Sometimes it is very useful to run several copies of Lotus Notes. Let's say in one client you run agent and in the same time you continue to work. Also it is very useful when you want to work with different servers at the same time with different IDs.

Here is approach how to do it!

1. We have to change the shortcut of notes: instead of launching a file notes.exe, you need to run nlnotes.exe
C: \ Lotus \ Notes \ nlnotes.exe "= C: \ Lotus \ Notes \ notes.ini"
For convenience, you can also rename the shortcut to "Notes 01"
2. Then we have to copy notes folder, for example in the folder C: \ Lotus \ Notes02
3. Modify notes.ini in new copy of Lotus Notes - we should correct the path with C: \ Lotus \ Notes \ to C: \ Lotus \ Notes02 \
4. Copy shortcut to run, it to "Notes 02, and the change the way.
C: \ Lotus \ Notes02 \ nlnotes.exe "= C: \ Lotus \ Notes02 \ notes.ini"
5. By using these shortcuts you can run two copies of lotus notes

If you repeat this, you can run any number of copies.

You can also change the color of notes desktop to don't forget which version you use now...

Wednesday, May 07, 2008

Evaluation of database

Simple example, how we can evaluation of database. Put this code in DatabaseScript on event PostOpen. I would like to see another examples, but I did not find

(Declarations)

Declare Function NEMGetCurrentSubprogramWindow Lib "nnotesws.dll" () As Long
Declare Function NEMStopSubprogramWindow Lib "nnotesws.dll" (Byval hwnd As Long) As Integer
Sub Postopen(Source As Notesuidatabase)
If Cdat("03/15/2009") < Cdat(Today) Then
Dim wHandle As Long
' Get window handle
wHandle = NEMGetCurrentSubprogramWindow
' Close current window
Call NEMStopSubprogramWindow(wHandle)
End If
End Sub

Add on by Olli Kämäräinen
We have to remember about international date, so here a solution how to fix potential problem...

Function MakeDate(dd As String, mm As String, yyyy As String) As Variant

Dim session As New NotesSession
Dim international As NotesInternational
Dim delim As String
Set international = session.International

delim = international.DateSep

If international.IsDateDMY Then
MakeDate = Cdat(dd & delim & mm & delim & yyyy)
'Messagebox "DMY",, "Format of date"
Elseif international.IsDateMDY Then
MakeDate = Cdat(mm & delim & dd & delim & yyyy)
Elseif international.IsDateYMD Then
MakeDate = Cdat(yyyy & delim & mm & delim & dd)
Else
'Messagebox "Unknown",, "Date"
End
End If

End Function

Tuesday, May 06, 2008

How to create PDF from Lotus Notes

I want to show you one of the way how we can create PDF documents from Lotus Notes. I propose to use this package com.lowagie.text
You can download iText®, a JAVA-PDF library
Read more here Generate PDF files from Java applications dynamically

Here is an example that create PDF document.
import lotus.domino.*;
import java.io.FileOutputStream;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Chapter;
import com.lowagie.text.Font;
import com.lowagie.text.List;
import com.lowagie.text.Table;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.pdf.PdfWriter;

public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
//create document's object
Document document = new Document();
try {
//create a document
PdfWriter.getInstance(document, new FileOutputStream("c:\\CreatePDFInlotus.pdf"));
//open doc for r/w
document.open();
//add text
document.add(new Paragraph ("Create PDF in Lotus "));
//if error
} catch (DocumentException de) {
System.err.println(de.getMessage()); }

document.close();

} catch(Exception e) {
e.printStackTrace();
}
}
}
Download Project: convert_2_pdf example

Related articles about creating PDF files

Monday, May 05, 2008

Discovering of memory leaks

You may have discovered memory leaks when your Notes client is running a large job or just running an application on your Domino server. The leaks can occur in various places — and the source of the problems may be almost impossible to identify in your code. Here are some undocumented techniques that can help you find code that might be causing memory leaks.
The trick is to know the name of a function call to some internal registers that will return the amount of memory in use. Here are the types of information returned and the function names:

LotusScript Memory Allocated: Lsi_info(50)
LotusScript Memory Allocated from OS: Lsi_info(51)
LotusScript Blocks Used: Lsi_info(52)

Here's a LotusScript code fragment that shows how to use these functions in a foreground agent:

Sub Initialize
Msgbox(" Total LotusScript Memory Allocated: " & (Lsi_info(50)))
Msgbox(" Total LotusScript Memory Allocated from OS: " & (Lsi_info(51)))
Msgbox(" Total LotusScript Blocks Used: " & (Lsi_info(52)))
End Sub

To determine whether a leak exists, you must run this code BEFORE and AFTER the portion of code you want to investigate. If you want to use the above code in a background agent, you must print the results to the LOG.NSF using code like this:

Sub Initialize
Print "Memory Allocated: " & CStr(Lsi_info(50))
Print "Total LotusScript Memory Allocated from OS: " & CStr(Lsi_info(51))
Print "Total LotusScript Blocks Used: " & CStr(Lsi_info(52))
End Sub

If you write the information to a document in a database (for example, your own log facility), be careful because this procedure also consumes some memory, and thus, the BEFORE and AFTER measurements will NOT be equal. Also, because these techniques are undocumented, use them at your own risk, and make sure you have good backups before implementing them.

ProgressBar example

There is a small progessBar.rar of this kind of dialog. There are only main page and LS library.

Display all private agents in a database

The first step to detemine what agent are running on each server is to issue a:

Tell Amgr Sched server command

This will display all agents running in each database whether they are private or not.


Now the really cool trick - Before one can delete an agent you have to be able to see them, right? And private agent is'nt visible because they're private, stating the obvious... But here's a neat workaround:

To display all private agents in a database, all you have to do is create another private agent! It doesn't have to contain any code just create the agent, save it and exit. All private agents are now visible and you can even remove your agent and they'll stay visible.

I checked it with R5, and R6.5 it works ! but with R7.03 and R8 it did not work

Saturday, May 03, 2008

cross language via URL

I finished one small project, where I had to add possibility to change language. I did not find the best solution/way how to do it in Internet. So, I did it how I wanted :)
In my case I had documents in database (=> HTML pages) with content. So, I added in every document (HTML's page) new fields with different content (for different language). I put content in different fields: content_en, content_it, content_ru... For opening document in every language I used next approach, look at these URL:
http://host/db.nsf/EN/F593D4CBD7E802FFC125742500638A22?opendocument
http://host/db.nsf/RU/F593D4CBD7E802FFC125742500638A22?opendocument
http://host/db.nsf/IT/F593D4CBD7E802FFC125742500638A22?opendocument

Then I added agent on QO event, and checked the name of "view" (EU/RU/IT), then took it and used it when I received content => "content_" & language.