Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add documents programmatically 1

Status
Not open for further replies.

tgerits

Programmer
Oct 5, 2001
23
BE
Hi,

I want to add documents in eg. the addressbook.
But I want to do this when I click a button or something. Thus within a LotusScript. Is it possible?


Thanks!!!


Greetz,
T.
 
With LotusScript you can interact with almost any element you include in the design of the database. From a technical point of view, creating documents is a trivial matter. From a programming point of view, that depends more on where the code is triggered, and what info do you need to fill the document with.
You refer to adding docs and using the Address book. Do you mean adding a new address when you receive a mail, or importing data from a different application (like, wild guess, Outlook) ?

Pascal.
 
It's from an excel-file with names and addresses. But not every address has to be imported. I have to check before I add the address to the addressbook.

I have following script:


Sub Click(Source As Button)
'Declare variables
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As notesDocument

'Initialize variables
Set db = session.Getdatabase("","names")
'names=Local AddressBook
Set doc = db.CreateDocument()
doc.Firstname = "dummy with script"
doc.Lastname="lastname dummy with script"
doc.IsSummary=True
Call doc.Save(True, False)
End Sub


Everything seems to go fine, I mean, there are no errors given, but when I look into my addressbook there are no new documents.

When I test on the items first like the following:

if doc.hasItem("Firstname") Then
Messagebox("firstname found")
End If

The messagebox is never displayed. How does Notes know that the document has to be created in the view "Contact".


Thanks!!!

Greetz,
T.
 
Indeed, you will see no new contacts because, although you have created a document and saved it, you have not told Notes that the document you created was a contact. Notes does not "know" you are creating a contact. Notes is just doing what you tell it to do ;-).
To do so, you must add another line in your code :

doc.form="Person"

Doing that will ensure that you will see the document in the Contact view.
Always specify what type of doc it is when you create one programmatically.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top