如何更改文档的字段值(LotusScript)?
在新的 LotusNotes 表单中,我有一个计算值字段(“NewOrdProdUID”),该字段使用另一个现有文档的唯一 ID 正确设置。 我想通过 LotusScript 更改现有文档中“NewProdAvail”字段的值。我尝试这样做:
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
但是“NewProdAval”字段的值保持不变(在我的例子中为 3,而不是 0)。 请帮我!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
奇怪的是,看来你也应该得到一个错误。您正在 NotesDocument 对象 (odoc) 上调用 NotesUIDocument 的前端方法,并且 NotesDocument 类没有名为“FieldSetText”的方法。这应该可以解决问题:
不要调用 odoc.FieldSetText("NewProdAvail", "0"),而是尝试这个
希望这有帮助!
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
Hope this helps!
NotesDocument 类没有 FieldSetText 方法。您可以使用:
或简单地:
The NotesDocument class does not have a FieldSetText method. You can use:
or simply:
前面的回答,告诉你如何在后端文档上设置字段。我认为值得一提的是后端和前端是如何工作的。
在为 Lotus Notes 客户端编码时,您需要记住 Notes 文档具有前端和后端组件。基本上,Lotus Client 中的Notes 文档都有一个前端内存版本和相应的后端内存版本。更改应在查询保存期间传播到后端,然后通过前端提交所做的更改。
因为前面的答案向您展示了如何直接更改后端文档,所以您还应该注意 NotesUIDocument 类上的“autoload”属性。 此链接很好地解释了这一点。其他可以“篡改”字段值设置的因素包括受影响字段中的公式以及该字段是否已计算或可编辑。
希望这有帮助。
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
and it worked. Thank you guys for the help!