lotus 编程学习笔记
- 格式:doc
- 大小:235.50 KB
- 文档页数:36
lotus 编程学习笔记
用NotesDatabase.search方法来统计符合条件的文档个数
-------------
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
'要搜索的文档的起始时间
Dim dateTime As New NotesDateTime("01/01/96")
Set db = session.CurrentDatabase
'Search 的第一个参数是用公式语言表达的搜索条件
Set collection = db.Search("Form = 'qj'",dateTime,0)
Messagebox collection.Count
End Sub
提示邮箱信息的代码
------------------------------
Dim s As New NotesSession
Dim db As NotesDatabase
Dim uname As String
Dim mailfileloc As Variant
Const MB_OK = 1
Const MB_ICONINFORMATION=64
boxtype& = MB_OK + MB_ICONINFORMATION
Set db=s.CurrentDatabase
uname = monUserName
srvname = Evaluate("@Name([CN];@Subset(@MailDBName;1))")
mailfileloc = Evaluate("@Subset(@MailDBName;-1)")
Dim mydb As New NotesDatabase( Cstr(srvname(0)), Cstr(mailfileloc(0)))
Msgbox "Server: " & srvname(0) & Chr$(13) _
& "Db directory and db name: " & mailfileloc(0) & Chr$(13) & Chr$(13)_
& "The size of your mail file is: " _
& Round(mydb.Size/1048576, 2) & "Mb", boxtype&, "Mail file of " & uname & "..."
建立/获取/修改简要表文档
-----------------------------------
示例4-2展示了怎样建立、获取、和修改简要表文档的示例。如果没有找到这个描述文
档 docProfile 那么就会建立它,然后,它就会检查这个文档中的值 Company字段。
如果没有设置这个字段,那么就会对其进行更新,并且保存新值。如果已经进行了设置 那么就不会再进行更多的处理。
示例4-2 建立/获取/修改简要表文档
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim docProfile As NotesDocument
Dim sAuthor As String
Dim itemCompany As NotesItem
Set db = session.CurrentDatabase
Set docProfile = db.GetProfileDocument("Profiles", erName)
Set itemCompany = docProfile.GetFirstItem("Company")
If itemCompany Is Nothing Then
pany = "ConCrea"
Call docProfile.save(True, False)
End If
End Sub
用公式打开“关于数据库”、“使用数据库”文档
-----------------------------------------
@Command([HelpAboutDatabase])
@Command([HelpUsingDatabase])
让组合框下拉时有一个空值可以选
--------------------------------
@Explode(@Char(255):"男":"女")
用Messagebox判断用户做出的选择
--------------------------------
Sub Click(Source As Button)
answer% = Messagebox("Do you want to continue?", 36, "Continue?")
If answer% = 6 Then
Messagebox "You cliked OK!"
Else
Messagebox "You cliked NO!"
End If
End Sub
@IsDocBeingEdited
-------------------------
检查文档的当前状态,如果文档正在被编辑,则返回 1 (True);否则返回 0 (False)。
语法
@IsDocBeingEdited
返回值
flag
布尔型
1 (True) 表示正在编辑该文档
0 (False) 表示不在编辑该文档
用法
该函数不能用于列公式、选择公式、代理、表单公式或视图操作公式中。常用于按钮公式、隐藏公式、域公式和表单操作公式中。
例:
tmp := @if(@IsDocBeingEdited; "在编辑状态";"不在编辑状态");
@prompt([OK]; "提示是否在编辑状态";tmp )
相关主题
@IsDocBeingLoaded
@IsDocBeingMailed
@IsDocBeingRecalculated
@IsDocBeingSaved
用NotesDocument后台类改变UI文档的域值
-------------------------------------------
Sub Click(Source As Button)
'改变当前文档中的Main_Status域值
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
doc.Main_Status = "5"
Call doc.Save( True, True )
End Sub
将当前文档置于编辑模式中
-----------------------------
@Command([EditDocument];"1")
使用LotusScript获得群组中的用户列表
---------------------------------------
Declarations
Dim count As Integer
Dim persons List As String
Dim groups List
Dim tg As Integer
Dim xy As Integer
Sub Initialize
'The advantate of this code is that we can process any nested groups without any size limitaions.
Dim session As New notessession
Dim ws As New notesuiworkspace
Dim uidoc As NotesUIDocument
Dim db As notesdatabase
Dim namesdb As notesdatabase
Dim groupdoc As notesdocument
Dim groupview As notesview
Dim insidegroupdoc As notesdocument
Dim insidegroups As notesview
Dim doc As notesdocument
Dim curview As notesview
Dim newlist List
Set db=session.CurrentDatabase
Set namesdb=session.GetDatabase(db.Server,"names.nsf")
Set groupview=namesdb.GetView("($Users)")
Set insidegroups=namesdb.getview("($VIMGroups)")
Set curview=db.getview("second")
Set uidoc=ws.CurrentDocument
Set doc=curview.getfirstdocument 'you can set your own doc here. This the backend document for
the currently opened uidoc. You can find other alternatives to run this agent.
groupName$ =uidoc.FieldGetText("names") ' Here we are entering the group or person names.
Dim ritem As Variant
Set ritem = doc.GetFirstItem( "all" ) ' Here we are going to store the group extracted people's
name