Link to home
Start Free TrialLog in
Avatar of Princeinal Suganthi
Princeinal Suganthi

asked on

creating a Notes document and notes item

Hi, I just tried a very simple code to create a document and to create a new item. Document gets created but not the new item.Below is the code:

Sub Initialize
      Dim Session As New NotesSession
    Dim db As NotesDatabase
    Dim doc1 As NotesDocument
    Dim item As NotesItem
    Set db = session.Currentdatabase
      Set doc1 = New NotesDocument(db)
            Set item = New NotesItem _
          (doc1, "ModifiedBy", session.UserName)
            
            Call doc1.save(True, True)
End Sub
New-Document.jpg
ASKER CERTIFIED SOLUTION
Avatar of Francois Koutchouk
Francois Koutchouk
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sjef Bosman
Where is this code? Is it an agent? How do you know that the item isn't created? Can you look up the document in a view and open the Document Properties dialog box? You may need to add a Form item if this is agent code, e.g.
     Call doc1.ReplaceItemValue("Form", "Discussion")
Avatar of Princeinal Suganthi
Princeinal Suganthi

ASKER

Thank you Francois Koutchouk and Sjef Bosman.

Yes I didn't know that the field should already exist to copy value to it.
I am new to Lotus Notes. Now my issue is solved.
Sorry, but I don't understand your last comment. Depending on where you have your code, there is no need that a field exists before you "copy a value to it". Can you show us the code that works for you? Thanks.