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")
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
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...
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
(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
Subscribe to:
Posts
(
Atom
)