有人能发现一个明显的原因,为什么我的保存功能没有保存表格中的字段?它会保存文档,但打开时字段为空。我正在使用以下代码:
Public Sub co_loopNamesAndSaveDocs()
'Dim variables
Dim s As New NotesSession
Dim thisDatabase As NotesDatabase
Set thisDatabase = s.CurrentDatabase
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
Dim currentDoc As NotesDocument
Set currentDoc = uidoc.Document
Dim newDoc As NotesDocument
Dim PersonNameField As NotesItem
Set PersonNameField = currentDoc.GetFirstItem("PersonName")
'Loop through values in PersonNameField and create a new document for each value found
Forall pName In PersonNameField.Values
Set newDoc = New NotesDocument (thisDatabase)
newDoc.Form="newLocationForm"
newDoc.StartDate = currentDoc.StartDate(0)
newDoc.EndDate = currentDoc.EndDate(0)
newDoc.Duration = currentDoc.Duration(0)
newDoc.StartTime = currentDoc.StartTime(0)
newDoc.EndTime = currentDoc.EndTime(0)
newDoc.Comments = currentDoc.Comments(0)
newDoc.Status = currentDoc.Status(0)
newDoc.LocationCode = currentDoc.LocationCode(0)
newDoc.PersonName = pName
Call newDoc.Save (True, False, False)
End Forall
End Sub
提前致谢。
答案 0 :(得分:4)
由于我没有在编码中看到明显的错误,我会说newDoc中的字段是空白的,因为currentDoc中的字段是空白的。由于currentDoc设置为uidoc.Document,这可能意味着您在前端和后端文档之间存在同步问题。即,您的uidoc中存在值,但在调用此代码之前尚未保存到后端。如果我是对的,请在分配currentDoc之前尝试调用uidoc.save()。如果您不想保存到后端,那么您应该使用uidoc.fieldGetText(“PersonName”)并解析值,而不是使用后端作为数据源。