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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LotusScript beginner need help

Status
Not open for further replies.

csiwa28

Programmer
Apr 12, 2001
177
From a response doc I have an action button that will open up a document (parent) by it UNID. The UNID is stored on a hidden field on the response doc called ParentID. When I click the button it says that the object variable is not set. I still don't understand the whole front and back end class variables (i.e which and when to use them). Here's what I have, what's wrong with it?

Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim parent As NotesDocument
Dim uidoc As NotesUIDocument
Dim w As New NotesUIWorkspace
Set db = session.CurrentDatabase
Set uidoc = w.currentdocument
Set doc = uidoc.document
Set parent = db.GetDocumentByUNID(doc.TCustID)
 
Here are a couple of tips and something to try:

1. To help you diagnose errors, run the code with the debugger turned on - it is very helpful in diagnosing (it would tell you which line your problem is on and you could look at the variable values as you step through the code).

2. Front and back end explanation: the front end references the current values displayed on the screen while back end references what has been saved to disk. The front end uidoc has all changes made since the last save, while the back end doc has what was saved. If you're manipulating documents from a view, you use the back-end document class to access the documents.

3. There is a ParentDocumentUNID property so you don't need to save the parent's UNID - the following code is adapted from the Notes Help examples on the ParentDocumentUNID property and it would work for you

Dim parent As NotesDocument
Dim uidoc As NotesUIDocument
Dim w As New NotesUIWorkspace
Set db = session.CurrentDatabase
Set uidoc = w.currentdocument
Set doc = uidoc.document
Set parent = db.GetDocumentByUNID( doc.ParentDocumentUNID )

4. All data field values in a document (back-end) are returned as arrays. If you were going to use your original code instead of the code in item 3 above, since you wanted a discreet value you need to change your last line to:

Set parent = db.GetDocumentByUNID(doc.TCustID(0))

The equivalent code using the current value in the uidoc is:

Set parent = db.GetDocumentByUNID( uidoc.FieldGetText( "TCustID" ))

If it were a multi-value field, each value would be like an array element.
 
I tried what you said. I have to store the UNID and use it, so I kept my original code but I just changed the last line to get the current value in the uidoc.

Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim parent As NotesDocument
Dim uidoc As NotesUIDocument
Dim w As New NotesUIWorkspace
Set db = session.CurrentDatabase
Set uidoc = w.currentdocument
Set doc = uidoc.document
Set parent = db.GetDocumentByUNID(uidoc.FieldGetText("TCustID"))

I don't get any error messages anymore, however when I click on the button it doesn't do anything. Any suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top