I'm having a problem saving a new document created using a lotus script. The situation is pretty weird to begin with. To make a long story short I'm having the user input the info on a form and then creating multiple documents based on the info inputed on the form.
Anyways, the problem I'm having is I create a new notesdocument (based on a projectTracking form) in a sub and start inputting info to the document. Then I call a function to create and save new notes document (based on a contactInfo form) and return the unigue key to the sub. I input the returned value into the notes document and then save the notes document. For some reason I'm ending up with a total of four notes document. I will have two projectTracking documents and two contactInfo documents. Each document type will have a blank document. When I go to the view and try to delete the blank contactInfo document the non-blank projectTracking document will also be deleted. And vica versa.
Does anyone have an idea of what is going on? Here is a sample of the code I'm using. (Please be kind I've only been writing Lotus Script for about two weeks now).
Any info would be greatly appreciated.
Thanks!!
Sub updateForms()
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim curdoc As NotesDocument
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim newID As Variant
Dim copyID As String
Dim ID As Double
Dim view As NotesView
Dim docView As NotesDocument
Dim ESGOwner As String
Dim ESGWorkNumber As String
Dim ESGHomeNumber As String
Dim ESGPagerNumber As String
Dim ESGFaxNumber As String
Dim ownerID As Double
Set uidoc = workspace.CurrentDocument
Set curdoc = uidoc.Document
Set db = session.CurrentDatabase
Set doc = New NotesDocument( db )
Set view = db.GetView( "GetNumber" )
Set docView = view.GetFirstDocument
newID = docView.GetItemValue( "ProjectID"
copID = Cstr(newID(0))
If copID = "" Or copID = " " Then
copID = "0"
End If
ID = Cdbl(copID)
ID = ID + 1
doc.Form = "ProjectTracking"
doc.BudgetYear = uidoc.FieldGetText("ESGBudgetYear"
doc.BudgetSubtype = uidoc.FieldGetText("ESGBudSubtype"
doc.SBU = uidoc.FieldGetText("ESGSBU"
doc.CID = uidoc.FieldGetText("ESGCIDNumber"
doc.SPMID = uidoc.FieldGetText("ESGSPMID"
doc.SublineID = uidoc.FieldGetText("ESGSublineID"
doc.PhaseNumber = uidoc.FieldGetText("ESGCIDPhase"
doc.ProjectTitle = uidoc.FieldGetText("ESGProjectTitle"
doc.ESGDesiredReleaseDate = uidoc.FieldGetText("ESGTargetReleaseDate"
doc.ImpactedStatus = uidoc.FieldGetText("ESGStatesImpacted"
doc.ProcessEmergencyRequest = uidoc.FieldGetText("ESGEmergencyRequest"
doc.MandatoryProject = uidoc.FieldGetText("ESGMandatoryProject"
doc.ProjectID = ID
ESGOwner = uidoc.FieldGetText("ESGOwner"
ESGWorkNumber = uidoc.FieldGetText("ESGWorkNumber"
ESGHomeNumber = uidoc.FieldGetText("ESGHomeNumber"
ESGPagerNumber = uidoc.FieldGetText("ESGPagerNumber"
ESGFaxNumber = uidoc.FieldGetText("ESGFaxNumber"
ownerID = addContacts(ESGOwner, ESGWorkNumber, ESGHomeNumber, ESGPagerNumber, ESGFaxNumber)
doc.ClientOwner = ownerID
Call doc.Save( False, False )
End Sub
Function addContacts( ownerName As String, work As String, home As String, pager As String, fax As String)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim docCon As NotesDocument
Set db = session.CurrentDatabase
Set docCon = New NotesDocument( db )
Dim newID As Variant
Dim copyID As String
Dim ID As Double
Dim view As NotesView
Dim docView As NotesDocument
Set view = db.GetView( "ContactNumber" )
Set docView = view.GetFirstDocument
newID = docView.GetItemValue( "ContactID"
copID = Cstr(newID(0))
If copID = "" Or copID = " " Then
copID = "0"
End If
ID = Cdbl(copID)
ID = ID + 1
docCon.Form = "ContactInfo"
docCon.ContactID = ID
docCon.Name = ownerName
docCon.workNum = work
docCon.homeNum = home
docCon.faxNum = fax
docCon.pagerNum = pager
Call docCon.Save( False, False)
addContacts = ID
End Function
Anyways, the problem I'm having is I create a new notesdocument (based on a projectTracking form) in a sub and start inputting info to the document. Then I call a function to create and save new notes document (based on a contactInfo form) and return the unigue key to the sub. I input the returned value into the notes document and then save the notes document. For some reason I'm ending up with a total of four notes document. I will have two projectTracking documents and two contactInfo documents. Each document type will have a blank document. When I go to the view and try to delete the blank contactInfo document the non-blank projectTracking document will also be deleted. And vica versa.
Does anyone have an idea of what is going on? Here is a sample of the code I'm using. (Please be kind I've only been writing Lotus Script for about two weeks now).
Any info would be greatly appreciated.
Thanks!!
Sub updateForms()
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim curdoc As NotesDocument
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim newID As Variant
Dim copyID As String
Dim ID As Double
Dim view As NotesView
Dim docView As NotesDocument
Dim ESGOwner As String
Dim ESGWorkNumber As String
Dim ESGHomeNumber As String
Dim ESGPagerNumber As String
Dim ESGFaxNumber As String
Dim ownerID As Double
Set uidoc = workspace.CurrentDocument
Set curdoc = uidoc.Document
Set db = session.CurrentDatabase
Set doc = New NotesDocument( db )
Set view = db.GetView( "GetNumber" )
Set docView = view.GetFirstDocument
newID = docView.GetItemValue( "ProjectID"
copID = Cstr(newID(0))
If copID = "" Or copID = " " Then
copID = "0"
End If
ID = Cdbl(copID)
ID = ID + 1
doc.Form = "ProjectTracking"
doc.BudgetYear = uidoc.FieldGetText("ESGBudgetYear"
doc.BudgetSubtype = uidoc.FieldGetText("ESGBudSubtype"
doc.SBU = uidoc.FieldGetText("ESGSBU"
doc.CID = uidoc.FieldGetText("ESGCIDNumber"
doc.SPMID = uidoc.FieldGetText("ESGSPMID"
doc.SublineID = uidoc.FieldGetText("ESGSublineID"
doc.PhaseNumber = uidoc.FieldGetText("ESGCIDPhase"
doc.ProjectTitle = uidoc.FieldGetText("ESGProjectTitle"
doc.ESGDesiredReleaseDate = uidoc.FieldGetText("ESGTargetReleaseDate"
doc.ImpactedStatus = uidoc.FieldGetText("ESGStatesImpacted"
doc.ProcessEmergencyRequest = uidoc.FieldGetText("ESGEmergencyRequest"
doc.MandatoryProject = uidoc.FieldGetText("ESGMandatoryProject"
doc.ProjectID = ID
ESGOwner = uidoc.FieldGetText("ESGOwner"
ESGWorkNumber = uidoc.FieldGetText("ESGWorkNumber"
ESGHomeNumber = uidoc.FieldGetText("ESGHomeNumber"
ESGPagerNumber = uidoc.FieldGetText("ESGPagerNumber"
ESGFaxNumber = uidoc.FieldGetText("ESGFaxNumber"
ownerID = addContacts(ESGOwner, ESGWorkNumber, ESGHomeNumber, ESGPagerNumber, ESGFaxNumber)
doc.ClientOwner = ownerID
Call doc.Save( False, False )
End Sub
Function addContacts( ownerName As String, work As String, home As String, pager As String, fax As String)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim docCon As NotesDocument
Set db = session.CurrentDatabase
Set docCon = New NotesDocument( db )
Dim newID As Variant
Dim copyID As String
Dim ID As Double
Dim view As NotesView
Dim docView As NotesDocument
Set view = db.GetView( "ContactNumber" )
Set docView = view.GetFirstDocument
newID = docView.GetItemValue( "ContactID"
copID = Cstr(newID(0))
If copID = "" Or copID = " " Then
copID = "0"
End If
ID = Cdbl(copID)
ID = ID + 1
docCon.Form = "ContactInfo"
docCon.ContactID = ID
docCon.Name = ownerName
docCon.workNum = work
docCon.homeNum = home
docCon.faxNum = fax
docCon.pagerNum = pager
Call docCon.Save( False, False)
addContacts = ID
End Function