English 中文(简体)
How to change a field value of a document (LotusScript)?
原标题:

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!

最佳回答

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!

问题回答

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

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

or simply:

odic.NewProdAvail = "0"

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.

I used

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

and it worked. Thank you guys for the help!





相关问题
Where are the javadocs for Lotus Notes.jar?

I need to use Lotus Notes/Domino as a data source from a Java application. The documentation at IBM says that the Notes.jar contains everything I will need, but where are the javadocs?

Is Interop.Domino dll thread safe?

I am using Interop.Domino dll version 1.2 in c# application, and using multithreading to access multiple NSF file at same time by creating new session for each thread created (Max 5 threads at a time)....

C#和Lotus Notes附录一

我正在使用C#,并需要附上一张空白(shortcut/link)档案和电子邮件给一个彩票账户。 问题是一对一幅通用形象的不实之词,没有像......那样显示双fold。

How to maintain Lotus Notes Version ? C#

I made one product which is retrieving attachment from mails and saving it on particular folder. But problem i am facing is it is not working in 8.0 version. I did development on Lotus Notes 8.5 ...

How to Edit NSF file using c#?

I want to programaticaly change some values to NSF item and then want to save it.(i.e to edit NSF File and then save the editions) for example: I want to set Sender name of all mails to "preeti@abc....

热门标签