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

Lotus notes 如何从其他选定文档中获取值并将值显示到一个文档中,lotus-notes,lotus-domino,lotusscript,Lotus Notes,Lotus Domino,Lotusscript,我有一份文件清单。我还有一个内部视图按钮,可以从现有文档中创建具有值的新文档。对于这个新文档,我将为创建的新文档使用不同的表单。在我看来,文件是按状态划分的。我还有dialogBox,可以为新文档设置batchNo 所以,这个过程是这样的: 首先,我将根据it状态选择文档。假设我有5个文档处于“损坏”状态,我可以选择需要多少文档。所以我只选择了两个文档 选中文档后,我将单击按钮使用lotusscript创建一个新文档。单击按钮后,将显示对话框。我插入batchNo并单击OK 然后,代码将检查文档

我有一份文件清单。我还有一个内部视图按钮,可以从现有文档中创建具有值的新文档。对于这个新文档,我将为创建的新文档使用不同的表单。在我看来,文件是按状态划分的。我还有dialogBox,可以为新文档设置batchNo

所以,这个过程是这样的:

  • 首先,我将根据it状态选择文档。假设我有5个文档处于“损坏”状态,我可以选择需要多少文档。所以我只选择了两个文档
  • 选中文档后,我将单击按钮使用lotusscript创建一个新文档。单击按钮后,将显示对话框。我插入batchNo并单击OK
  • 然后,代码将检查文档的状态,并通过从3个文档中获取值并显示到新文档中来创建新文档
  • 例如,我需要从2个文档的字段“PSerialNo”和“PType”中获取值。正如你在下面看到的。值,我想在新文档中插入。因此,如果将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
    

    嘿,谢谢你的回答。我一直在尝试您的解决方案,但GetItemValue似乎不正确,因为它向它所需的变量显示了错误。你知道吗?同样在docCreated中,需要同时调用ComputeWithForm和save.:)好吧,没关系,我修好了。我会更新你的答案