I need to create person docs programmiclyfrom a lookup db that is populated from a db2 table. I have tried the below code but it wants a user ID file.
I need to do this so that I can allow users to access a web site with a login and password.
I do not want users creating this on there own.
So my question is, How do I create person docs programmicly?
Dim reg As New NotesRegistration
reg.RegistrationServer = “Regional/ElectricMobility”
reg.StoreIDInAddressBook = False
Call reg.AddUserToAddressBook(“”, gFullName, gLName, gHomePhone, gFName, " ", " ", " ", gEMailAdd, gCity, " ")
Subject: Create Person docs
If you are just creating Web Users without mail or a user id, you do not need to use the NotesRegistration class. You just need to create the person docs in names.nsf (or some other cascaded directory) using the CreateDocument method. That way it will happen immediately and you will not have to wait for AdminP.
Subject: RE: Create Person docs
I did that with the below and it would not create it
'Set docNAB = db2.CreateDocument
'docNAB.Form = "Person"
'docNAB.FirstName = gFName
'docNAB.LastName = gLName
'docNAB.FullName = gFullName
'docNAB.ShortName = gRepNo
'docNAB.HTTPPassword = gRepNo
'docNAB.InternetAddress = gEMailAdd
'docNAB.OfficeCity = gCity
'docNAB.OfficeState = gState
'docNAB.Level0 = gDivision
'hName$(gFullName) = gFullName
'Call docNAB.Save (True, False)
Subject: I assume that those lines were commented out after the fact?
Are you saying that the document was not created in the NAB or that the person was not able to log in?If that was the case then you need:
docNAB.HTTPPassword = Evaluate(|@Password(“| + gRepNo + |”)|, docNAB)
or if you use stronger quality passwords:
docNAB.HTTPPassword = Evaluate(|@HashPassword(“| + gRepNo + |”)|, docNAB)
Subject: RE: I assume that those lines were commented out after the fact?
I am saying that the person doc is not being created at all
Subject: Please post the full code
Subject: RE: Please post the full code
With this below code, the person doc gets created but I had to make a special view to see the doc, edit and save it for the doc to show up in the normal views in the nab
Dim s As New NotesSession
Dim db As NotesDatabase
Dim db2 As NotesDatabase
Dim View As NotesView
Dim doc As NotesDocument
Dim docNAB As NotesDocument
'Dim hName List As String
Dim gFName As String
Dim gLName As String
Dim gRepNo As String
Dim gHomePhone As String
Dim gEMailAdd As String
Dim gDivision As String
Dim gCity As String
Dim gState As String
Dim gFullName As String
Set db = s.CurrentDatabase
Set db2 = New NotesDatabase("Regional/ElectricMobility", "names.nsf")
'Set view = db.GetView("LKSendNAB")
'Set doc = view.GetFirstDocument
Set collection = db.unprocesseddocuments
Set doc = collection.GetFirstDocument
While Not (doc Is Nothing )
gFName = doc.SRFNM(0)
gLName = doc.SRLNM(0)
gRepNo = doc.SRFSR(0)
gHomePhone = Cstr(doc.SRHPH(0))
gEMailAdd = doc.SRINET(0)
gDivision = doc.SREDIV(0)
gCity = doc.SRMCTY(0)
gState = doc.SRMST(0)
gFullName = gFName & " " & gLName
Set docNAB = db2.CreateDocument
docNAB.Form = "Person"
docNAB.FirstName = gFName
docNAB.LastName = gLName
docNAB.FullName = gFullName
docNAB.ShortName = gRepNo
docNAB.HTTPPassword = Evaluate(|@Password("| + gRepNo + |")|, docNAB)
docNAB.InternetAddress = gEMailAdd
docNAB.OfficeCity = gCity
docNAB.OfficeState = gState
docNAB.Level0 = gDivision
Call docNAB.ComputeWithForm( True, False )
'hName$(gFullName) = gFullName
Call docNAB.Save (True, False)
'Set doc = view.GetNextDocument(doc)
Set doc = collection.GetNextDocument(doc)
Wend
Subject: RE: Please post the full code
-
Is “Regional/ElectricMobility” the same server the agent is running on? If it is, use db.server instead.
-
Does the signature on the agent have the right to create documents in the Directory?
-
Take out the ComputeWithForm. That is what is likely messing you up. It gains you nothing except for failed validations. You will have to set fields that are required manually or run a refesh on the documents when done.
Subject: Add this: docNAB.Type = “Person”