如何从其他选定文档中获取价值并将价值显示到一个文档中

How to get value from other selected documents and display value into one document

我有一个文档列表正在查看。我在视图内还有一个按钮,我可以在其中创建具有现有文档值的新文档。对于这个新文档,我将使用不同的表格来创建新文档。在我看来,文档是按状态划分的。我也有对话框,我可以为新文档设置 batchNo。

所以,过程是这样的:

  1. 首先,我会select 文档基于它的状态。假设我有 5 个文档处于 "Spoilt" 状态,我可以选择我想要的文档数量。所以我只选择了2个文件。
  2. 完成文档 select 编辑后,我将单击按钮使用 lotusscript 创建一个新文档。单击按钮后,将显示对话框。我插入 batchNo 并单击确定。
  3. 然后,代码将检查文档的状态并通过从 3 个文档中获取值并显示到新文档中来创建新文档。
  4. 例如,我需要从 2 个文档的字段 "PSerialNo" 和 "PType" 中获取值。正如您在下面看到的。来自 document1 和 document2 的值,我想插入到新文档中。所以如果是document1,PSerialNo变成WSerialNo1,PType变成WType1。而如果是document2,PSerialNo变成WSerialNo2,PType变成WType2等等。

文档 1

文档 2

新建文档

这是我创建新文档的代码。

Set doc = dc.GetFirstDocument()

While Not (doc Is Nothing)
    If doc.PStatus(0) = "Active" Then
        Set newdoc = New NotesDocument(db)
        newdoc.Form = "WriteOff"            

        newdoc.WABatchNo = wDialogDoc.WBatchNo(0)
        newdoc.WType = doc.PType(0)
        newdoc.WSerialNo = doc.PSerialNo(0)

        newdoc.ComputeWithForm(False,False)
        newdoc.save(True,False)

    End If
    doc = dc.GetNextDocument(doc)
Wend

我现在的问题是,如果我创建新文档,并且想从两个文档中获取值,它不会插入到一个新文档中,而是插入到两个不同的新文档中。我该如何解决它。我感谢任何建议或帮助。谢谢!

我写 LotusScript 已经 10 多年了,所以我可能是错的。

Set doc = dc.GetFirstDocument()
Dim docCreated As Boolean 'flag a document was created
Dim i As Integer 'index for each document

docCreated = False
i = 0
While Not (doc Is Nothing)
    If doc.PStatus(0) = "Active" Then
        If Not docCreated Then 'only create a document for first doc
            Set newdoc = New NotesDocument(db)
            newdoc.Form = "WriteOff"
            docCreated = True
        End If
        i = i + 1

        newdoc.WABatchNo = wDialogDoc.WBatchNo(0)
        ' not sure about this part, but the idea is to set WType1 for first doc, WType2 for 2nd doc, and so on
        Call newdoc.ReplaceItemValue("WType" & i, doc.PType(0))
        Call newdoc.ReplaceItemValue("WSerialNo" & i, doc.PSerialNo(0))
    End If
    doc = dc.GetNextDocument(doc)
Wend

If docCreated Then
    Call newdoc.ComputeWithForm(False,False)
    Call newdoc.save(True,False)
End If