I’m having such a hard time with what appears to be simplistic. Behind a button I’m trying to open up another database (on another server) and bring in some of the data to populate some fields while keeping it open to finish working on it. The button is in the body of an email notification and I want to start a work order on it bringing the email subject into a field on the new work order document. I want this new work order document to remain open so that it can be filled out by the user. I’m out of steam, training scheduled in May, please help…
Sub Click(Source As Button)
Dim session As NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set session = New NotesSession
Set db = session.CurrentDatabase
Set doc = session.DocumentContext
Dim server As String
Dim wrdb As NewNotesDatabase (“”, “”)
Dim wrdoc As NewNotesDocument
Set server = “ISDDEV”
Set wrdb = New NotesDatabase( server, “\applications\request_tracking\isdrequesttracking.nsf” )
Set wrdoc = workspace.ComposeDocument
Call wrdoc.ReplaceItemValue(“Form”, “WorkOrder”)
Call wrdoc.ReplaceItemValue( “Location”, “Testing in the Location” )
End Sub
Subject: A few things
Sub Click(Source As Button)
Dim session As NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set session = New NotesSession
Set db = session.CurrentDatabase
Set doc = session.DocumentContext
Dim server As String
Dim wrdb As NewNotesDatabase (“”, “”)
Dim wrdoc As NewNotesDocument
Set server = “ISDDEV”
Set wrdb = New NotesDatabase( server, “\applications\request_tracking\isdrequesttracking.nsf” )
Set wrdoc = workspace.ComposeDocument This returns a NOtesUIDocument not a NotesDocument
Call wrdoc.ReplaceItemValue(“Form”, “WorkOrder”) Use FieldAppendText of the NotesUIDocument to set the fields
Call wrdoc.ReplaceItemValue( “Location”, “Testing in the Location” )
For the subject of the email use the doc variable to get the subject field like doc.subject(0)
Then use uidoc.FieldAppendText(“MyField”, doc.subject(0))
End Sub
I suggest you consider some training. Check out LotusScript Exam offer
We also have a free LS course.
Howard
Subject: Lotus Script Help (Beginner Style)
Everyone has to start somewhere. If you are trying to create a form from another db in the client, then this probably won’t be easy to do in your current workspace. Compose only works in ui…you may need to have your button create the document on the backend, then try to open.
Here’s at least the correct code to open the other db. You need to dim your uiworkspace.
Dim session As NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim workspace As New NotesUIWorkspace
Set session = New NotesSession
Set db = session.CurrentDatabase
Set doc = session.DocumentContext
Call workspace.OpenDatabase("servername", "dbname.nsf")
Subject: RE: Lotus Script Help (Beginner Style)
Thanks Landa. I will start from here. I appreciate the posts here. Funny the other guy was putting me down and trying to sell me TLCC courses. Well this is exactly the skillset that TLCC delivers, we own them. Thanks again.
Subject: Lotus Script Help (Beginner Style)
You can try something like the following:
Set wrdb = New NotesDatabase( server, “\applications\request_tracking\isdrequesttracking.nsf” )
'Set wrdoc = workspace.ComposeDocument ← commented out
Set wrdoc = new NotesDocument ( wrdb ) 'Create new doc in target db.
dim ws as New NotesUIWorkspace
dim uiwrdoc as NotesUIDOcument 'Normally these dims would be with other dim statements at the top of the sub
Set uiwrdoc = ws.EditDocument ( true, wrdoc ) 'Look at the help file for the other optional parameters.
'Call wrdoc.ReplaceItemValue(“Form”, “WorkOrder”) ← commented out
wrdoc.Form = “WorkOrder” "Alternative, simpler syntax to set a field value.
Call wrdoc.ReplaceItemValue( “Location”, “Testing in the Location” )
Note that uiwrdoc refers to the “front end” (i.e. user interface) and wrdoc refers to the back end (i.e. the database). They are two different ways of working with the same document.