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

时间:2019-05-31 01:22:16

标签: lotus-notes lotus-domino lotusscript

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

所以,过程是这样的:

  1. 首先,我将根据其状态选择文档。假设我有5个处于“已损坏”状态的文档,我可以选择想要的文档数量。所以我只选择2个文档。
  2. 选择文档后,我将单击按钮以使用lotusscript创建一个新文档。单击按钮后,将显示对话框。我插入batchNo,然后单击“确定”。
  3. 然后,代码将检查文档的状态并通过从3个文档中获取价值来创建新文档并显示在新文档中。
  4. 例如,我需要从2个文档中的字段“ PSerialNo”和“ PType”中获取值。如下所示。来自document1和document2的值,我想插入新文档中。因此,如果为document1,则将PSerialNo转换为WSerialNo1,将PType转换为WType1。如果是document2,则将PSerialNo转换为WSerialNo2,将PType转换为WType2,依此类推。

文档1
doc1
文档2
doc2
新文档
newdoc

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

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

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

1 个答案:

答案 0 :(得分:1)

我编写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
相关问题