views:

881

answers:

4

Hello. In a new LotusNotes form I have a computed-value field ("NewOrdProdUID") which is set correctly with the unique ID of another existing document. I want to change the value of the field "NewProdAvail" in the existing document by means of LotusScript. I tried with this:

Sub Querysave(Source As Notesuidocument, Continue As Variant)
 Dim session As NotesSession
 Dim db As NotesDatabase
 Dim ws As New NotesUIWorkspace
 Dim uidoc As notesUIDocument
 Dim odoc As notesDocument 

 Set session = New NotesSession
 Set db = session.CurrentDatabase
 Set uidoc = ws.CurrentDocument

 Set odoc = db.GetDocumentByUNID(uidoc.FieldGetText("NewOrdProdUID"))
 Call odoc.FieldSetText("NewProdAvail", "0")
 Call odoc.Save(True, True)
End Sub

However the value of the field "NewProdAval" stays the same (3 in my case, not 0). Please, help me!

+2  A: 

Strange, it seems like you should be getting an error too. You are calling a front-end method for NotesUIDocument on your NotesDocument object (odoc), and the NotesDocument class does not have a method called "FieldSetText". This should fix the problem:

Instead of Call odoc.FieldSetText("NewProdAvail", "0"), try this

Call odoc.ReplaceItemValue("NewProdAvail", "0")

Hope this helps!

Ken Pespisa
+1  A: 

The NotesDocument class does not have a FieldSetText method. You can use:

odoc.replaceItemValue ("NewProdAvail", "0")

or simply:

odic.NewProdAvail = "0"
Ed Schembor
+1  A: 

I used

Set Item = odoc.replaceItemValue ("NewProdAvail", restAvailable)
Call odoc.Save(True, True)

and it worked. Thank you guys for the help!

Vassilen Dontchev
Consider showing your appreciation by accepting one of the answers.
Anders Lindahl
A: 

The previous answers, tell you how to set the field on the back-end document. I think it worth mentioning how the back-end and front-end work.

When coding for the Lotus Notes client you need to remember that a Notes document has a front-end and back-end components. Basically, Notes documents in the Lotus Client has a front-end memory version and a corresponding back-end memory version as well. Changes should propagate to the back end during querysave and then commit the changes you make via the front-end.

Because the previous answers are showing you how to change the back-end document directly, you should also be aware of the "autoload" property on the NotesUIDocument class. This link explains it well. Other things that can "tamper" with the setting of field values, are formula in the effected fields, and whether the field is computed, or editable.

Hope this helps.

giulio