Here's what's up:
We have a leave accounting system. One of the fields in the document is DEPARTMENT. All of the views are based on DEPARTMENT so the supervisor of the department can see all the leave requests from that department. The field in the document is populated from the Notes Address database. However, in a recent move, we reorganized the departments and now I need to go back into the leave accounting database and update all the departments. So I have written a LotusScript agent that will get the name from the Leave Accounting database document, open the Notes Address database, find that person's name, get their new department and update the leave accounting with the new department.
The reason for this update is that there are still pending leave requests that the supervisor's can't see in the view since they have a different department name.
However, we have leave requests for people who no longer work here. So when I try to get the information from the Notes Address book there is no person who matches. What property or method do I need to use to see if a variable has been initialized?
Here's the script:
Leslie
We have a leave accounting system. One of the fields in the document is DEPARTMENT. All of the views are based on DEPARTMENT so the supervisor of the department can see all the leave requests from that department. The field in the document is populated from the Notes Address database. However, in a recent move, we reorganized the departments and now I need to go back into the leave accounting database and update all the departments. So I have written a LotusScript agent that will get the name from the Leave Accounting database document, open the Notes Address database, find that person's name, get their new department and update the leave accounting with the new department.
The reason for this update is that there are still pending leave requests that the supervisor's can't see in the view since they have a different department name.
However, we have leave requests for people who no longer work here. So when I try to get the information from the Notes Address book there is no person who matches. What property or method do I need to use to see if a variable has been initialized?
Here's the script:
Code:
Sub Initialize
Dim session As New notessession
Dim db As notesdatabase
Dim collection As notesdocumentcollection
Dim doc As notesdocument
Dim count As Long
Dim newdepartment As NotesItem
Dim olddepartment As NotesItem
Dim LeaveName As Variant
Dim strName As String
Dim maildb As NotesDatabase
Dim mailview As NotesView
Dim maildoc As NotesDocument
Set maildb = New NotesDatabase( "domino1", "names.nsf" )
Set mailview = maildb.GetView( "People" )
Set db=session.currentdatabase
Set collection=db.AllDocuments
searchFormula$ = "Status != ""Approved"" & Status != ""Rejected"""
Set collection = db.Search(searchFormula$,Nothing,0)
for count=1To collection.count
'assign leave document to doc
Set doc=collection.getnthdocument(count)
'get mail information based on name to get new division for leave document
LeaveName = doc.GetItemValue("Name")
If Cstr(LeaveName(0)) <> "" Then
If Instr(Cstr(LeaveName(0)), "CN") = 0 Then
strName = Strright(Cstr(LeaveName(0)), " ") & " , " & Strleft(Cstr(LeaveName(0)), " ")
Set maildoc = mailview.GetDocumentByKey(strName)
[COLOR=red]
'Here is where I'm having the problem. If there is no matching document and maildoc hasn't been set to anything, I want to move to the next leave document.[/color]
If maildoc [COLOR=red]is SOMETHING[/color] Then
Set newdepartment = maildoc.GetFirstItem( "Department" )
Set olddepartment = doc.ReplaceItemValue("Department", newdepartment)
End If
End If
End If
Next
End Sub
Leslie