Solved

How to create a document w/  a specific form using LotusScript

Posted on 2002-03-28
3
437 Views
Last Modified: 2013-12-18
I need to be able to create a document in a notes database using a particular form named "test", set its variables to specific values, and perform a file attachment.

With the below code, I can successfully create a ducument, but I have been unable to create a document using a specific form.

Would like to create from scratch, but if I ahve to find the last one and clone it, etc. that's okay.  I just need something that works.


Note:

I am doing this from a VB app.


Sub cmdOpen_Click()


Dim db As New Domino.NotesDatabase
Dim session As New Domino.NotesSession

Dim object As Domino.NotesEmbeddedObject
Dim Body As Domino.NotesRichTextItem


' Set up error handling
On Error GoTo errhandler

' Create a Notes session
Set session = New Domino.NotesSession
 
 ' Initialize Notes Session
Call session.Initialize("thepassword")
 
 'Open the Notes Database
Set db = session.GetDatabase("", "test5.nsf")
 
If db.IsOpen = True Then
   Set doc = db.CreateDocument
    'Dim doc As New NotesDocument


     'doc.Form = "test"
     'doc.duration = 5
     'doc.JobCat = "test2"
     'doc.employee = s.UserName
     'doc.Customer = "Isn't this Cool?"
     'doc.Start = Now()
     'doc.End = Now()
     
    If (Body Is Nothing) Then Set Body = doc.CreateRichTextItem("Body")
    Set object = Body.EmbedObject(1454, "", "c:\test.txt")
    Call doc.Save(True, False)

             
 Else
        ' Put a messagebox or something here alerting user to fact that database could not bve opened.
 End If



 'Clean up memory
 Set doc = Nothing
 Set db = Nothing
 Set object = Nothing

Exit Sub
0
Comment
Question by:DLeader
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 200 total points
ID: 6903495
The COM vary little bit, here is how your code becomes a workable one.

Dim session
Dim db
Dim object
Dim Body


' Set up error handling
'On Error GoTo errhandler

' Create a Notes session
Set session = CreateObject("Lotus.NotesSession")

' Initialize Notes Session
Call session.InitializeUsingNotesUserName("USER", "PASSWORD")
' Call session.Initialize("thepassword")



'Open the Notes Database
Set db = session.GetDatabase("", "test.nsf")

If db.IsOpen = True Then
    Set doc = db.CreateDocument
    Call doc.ReplaceItemValue("Form", "Test")
    Call doc.ReplaceItemValue("Duration", 5)
    Call doc.ReplaceItemValue("JobCat", "test2")
    Call doc.ReplaceItemValue("employee", session.UserName)
    Call doc.ReplaceItemValue("Customer", "Isn't this Cool?")
    Call doc.ReplaceItemValue("Start", Now())
    Call doc.ReplaceItemValue("End", Now())
    Set Body = doc.CreateRichTextItem("Body")
    Set object = Body.EmbedObject(1454, "", "c:\test.txt")
    Call doc.Save(True, False)
Else
       ' Put a messagebox or something here alerting user to fact that database could not bve opened.
End If



'Clean up memory
Set doc = Nothing
Set db = Nothing
Set object = Nothing

~Hemanth
0
 

Author Comment

by:DLeader
ID: 6903523
Excellent work.  I looked all over for this answer.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6903732
You are welcome anytime .
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Lotus Notes Mail Database issues 2 849
Lotus Notes 6.5.5 6 200
Lotus notes email code 2 113
Only send email if contains "abcd" 3 135
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now