Lotus notes Lotus Domino无法将子文档从一个文档移动到另一个文档?

Lotus notes Lotus Domino无法将子文档从一个文档移动到另一个文档?,lotus-notes,lotus-domino,lotusscript,Lotus Notes,Lotus Domino,Lotusscript,我们的Domino开发人员告诉我们,在文档之间移动子文档在技术上是不可能的。这是真的吗 今年早些时候,他为我们编写了一个带有以下数据库图的课程注册系统: 现在我们问他如何将候补登记者从完整培训课程转移到非完整培训课程。他说这是不可能的。他说,我们需要重新输入(手动重新创建、复制和粘贴)等待名单记录,因为Domino无法将与会者从一个会议转移到另一个会议 我们的等待名单上有1000多名与会者 他说得对吗?这是真的吗?我们希望找到解决方案。如何做取决于文档的链接方式。但在任何情况下,都应该可以使用

我们的Domino开发人员告诉我们,在文档之间移动子文档在技术上是不可能的。这是真的吗

今年早些时候,他为我们编写了一个带有以下数据库图的课程注册系统:

现在我们问他如何将候补登记者从完整培训课程转移到非完整培训课程。他说这是不可能的。他说,我们需要重新输入(手动重新创建、复制和粘贴)等待名单记录,因为Domino无法将与会者从一个会议转移到另一个会议

我们的等待名单上有1000多名与会者


他说得对吗?这是真的吗?我们希望找到解决方案。

如何做取决于文档的链接方式。但在任何情况下,都应该可以使用代码(formula/lotusscript/java)重新链接文档

LotusDesigner的帮助包含了很多关于应用程序开发的信息。另一个资源是

有很多与莲花有关的

从Lotus Designer帮助中: MakeResponse:使一个文档成为对另一个文档的响应。这两个文档必须位于同一数据库中

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim docA As NotesDocument
Dim docB As NotesDocument
Set db = session.CurrentDatabase
Set view = db.GetView( "All documents" )
Set docA = view.GetFirstDocument
Set docB = view.GetNextDocument( docA )
Call docB.MakeResponse( docA )
docB.Form = "Response"
Call docB.Save( True, True )

有两种方式可以链接文档: -通过按键,软的方式 -层次结构,使用文档响应链接(即父子关系)

如果只有逻辑链接,使用键,则只需调整键字段。如果有一个“物理”文档响应链接,您可以轻松地断开并重新创建该链接。在LotusScript中,有NotesDocument.MakeResponse方法可以将任何文档附加到新的父级。如果同时使用这两种方法,当然是多余的,但在需要恢复某些链接时是实用的,则需要同时进行这两种更改。通常,一些关键字段会在父级和子级之间重复

仅出于测试目的,您可以尝试以下方法: -选择要挂起到其他位置的响应文档 -Ctrl-X -选择新的父文档 -Ctrl-V


在测试数据库中执行此操作,因为键字段不会自动更新。顺便说一下:粘贴这样的响应文档后,可以编写代码来修复键。

如果要保留现有文档,可以通过编程方式复制/复制它们。 使用copyAllItems方法很容易

查看Domino帮助(附示例)

您可以使用notesView对象(getFirstDocument()/getNextDocument()方法)迭代文档,在notesdocument.responses方法上迭代响应


相信我们,Domino是可能的,它是灵活的:-)

在您描述的数据模型中,这些数据基本上有两种链接方式。如果数据通过响应文档层次结构链接,则与基于键的文档结构略有不同

向您的开发人员展示这一点,他应该能够插入代码以满足您所说的“移动与会者”需求

有几件事需要注意

  • 我假设您需要处理的所有数据都在一个数据库中
  • 我把你提供的图表照字面理解
  • 对于基于键的文档结构,您需要检查用于查找与会者文档的视图和键值。具体检查“MoveAttendeeSkeybase”子项中的这两行:

    设置VWATENDESBYCOURSEID=db.GetView(“(LkupAllAttendeesByCourseID)”)

    设置dcAttendes=vwateendesbycourseId.GetAllDocumentsByKey(docCourseFrom.CourseID(0),True)

  • 该代码旨在查看名为“CourseID”、“Status”的字段和“Wait Listed”的值,以获取要移动的与会者的状态值

  • 编写此函数的两个版本大约需要20分钟

用于基于响应的文档结构

Sub MoveAttendeesResponseBased(docCourseFrom As notesDocument, docCourseTo As NotesDocument)
%REM
    A simple move attendees function if the relationship between courses and attendees is based on
    response document hierarchies
%END REM
    On Error Goto errHandle
    Dim dcAttendees As notesDocumentCollection
    Dim docAttendee As notesDocument
    Dim iAvailablePlaces As Integer
    Dim bMoved As Boolean

    If Not (docCourseFrom Is Nothing Or docCourseTo Is Nothing) Then        
        iAvailablePlaces = docCourseTo.availablePlaces(0)
        If 0 < iAvailablePlaces Then
            bMoved = False
            Set dcAttendees = docCourseFrom.Responses
            Set docAttendee = dcAttendees.GetFirstDocument
            While Not docAttendee Is Nothing And 0 < iAvailablePlaces
                If Ucase(Trim(docAttendee.Status(0)))= "WAIT LISTED" Then
                    Call docAttendee.MakeResponse(docCourseTo)
                    If docAttendee.Save(True,True) Then
                        iAvailablePlaces = iAvailablePlaces - 1
                        bMoved = True
                    End If
                End If
                Set docAttendee = dcAttendees.GetNextDocument(docAttendee)
            Wend
            If bMoved Then
                docCourseTo.availablePlaces = iAvailablePlaces
                Call docCourseTo.Save(True,False)
            End If
        End If
    End If  
    Exit Sub
errHandle:
    Messagebox Lsi_info(2) + " - " + Str(Err) + " : " + Error(Err) + ", at line " + Str(Erl)
    Exit Sub
End Sub
Sub MoveAttendeesKeyBased(docCourseFrom As notesDocument, docCourseTo As notesDocument)
%REM
    A simple move attendees function if the relationship between courses and attendees uses 
    (non-response) key based documents
%END REM
    On Error Goto errHandle
    Dim session As New notesSession
    Dim dcAttendees As notesDocumentCollection
    Dim docAttendee As notesDocument
    Dim iAvailablePlaces As Integer
    Dim bMoved As Boolean
    ' a view that lists attendees by Course ID
    Dim vwAttendeesByCourseID As notesView
    Dim db As notesDatabase

    If Not (docCourseFrom Is Nothing Or docCourseTo Is Nothing) Then        
        iAvailablePlaces = docCourseTo.availablePlaces(0)
        If 0 < iAvailablePlaces Then
            Set db = session.CurrentDatabase
            ' do a lookup of all attendees based on the CourseFrom document course id
            Set vwAttendeesByCourseID = db.GetView("(LkupAllAttendeesByCourseID)")
            ' this is the collection of all attendees under the CourseFrom document
            Set dcAttendees = vwAttendeesbyCourseID.GetAllDocumentsByKey(docCourseFrom.CourseID(0), True)
            bMoved = False
            Set docAttendee = dcAttendees.GetFirstDocument
            ' While there are attendee documents to process and there are available places to goto
            While Not docAttendee Is Nothing And 0 < iAvailablePlaces
                ' if the attendee's status is "Wait Listed" then move them
                If Ucase(Trim(docAttendee.Status(0)))= "WAIT LISTED" Then
                    ' Update the course ID for the Attendee
                    docAttendee.CourseID = docCourseTo.CourseID(0)
                    If docAttendee.Save(True,True) Then
                        ' decrement the available places
                        iAvailablePlaces = iAvailablePlaces - 1
                        bMoved = True
                    End If
                End If
                Set docAttendee = dcAttendees.GetNextDocument(docAttendee)
            Wend
            If bMoved Then
                ' available places may be >= 0. Just update the available places so you don't over book the course
                docCourseTo.availablePlaces = iAvailablePlaces
                Call docCourseTo.Save(True,False)
            End If
        End If
    End If  
    Exit Sub
errHandle:
    Messagebox Lsi_info(2) + " - " + Str(Err) + " : " + Error(Err) + ", at line " + Str(Erl)
    Exit Sub
End Sub
Sub-moves AttendenceResponseBased(docCourseFrom As notes文档,docCourseTo As notes文档)
%雷姆
如果课程和与会者之间的关系基于
响应文档层次结构
%终止REM
关于错误转到错误句柄
Dim DCAttenders As notes文档集合
Dim docAttendee As notes文档
Dim iAvailablePlaces为整数
模糊b移动为布尔值
如果不是(docCourseFrom为Nothing或docCourseTo为Nothing),则
IAAvailablePlaces=docCourseTo.availablePlaces(0)
如果0
用于基于密钥的文档结构

Sub MoveAttendeesResponseBased(docCourseFrom As notesDocument, docCourseTo As NotesDocument)
%REM
    A simple move attendees function if the relationship between courses and attendees is based on
    response document hierarchies
%END REM
    On Error Goto errHandle
    Dim dcAttendees As notesDocumentCollection
    Dim docAttendee As notesDocument
    Dim iAvailablePlaces As Integer
    Dim bMoved As Boolean

    If Not (docCourseFrom Is Nothing Or docCourseTo Is Nothing) Then        
        iAvailablePlaces = docCourseTo.availablePlaces(0)
        If 0 < iAvailablePlaces Then
            bMoved = False
            Set dcAttendees = docCourseFrom.Responses
            Set docAttendee = dcAttendees.GetFirstDocument
            While Not docAttendee Is Nothing And 0 < iAvailablePlaces
                If Ucase(Trim(docAttendee.Status(0)))= "WAIT LISTED" Then
                    Call docAttendee.MakeResponse(docCourseTo)
                    If docAttendee.Save(True,True) Then
                        iAvailablePlaces = iAvailablePlaces - 1
                        bMoved = True
                    End If
                End If
                Set docAttendee = dcAttendees.GetNextDocument(docAttendee)
            Wend
            If bMoved Then
                docCourseTo.availablePlaces = iAvailablePlaces
                Call docCourseTo.Save(True,False)
            End If
        End If
    End If  
    Exit Sub
errHandle:
    Messagebox Lsi_info(2) + " - " + Str(Err) + " : " + Error(Err) + ", at line " + Str(Erl)
    Exit Sub
End Sub
Sub MoveAttendeesKeyBased(docCourseFrom As notesDocument, docCourseTo As notesDocument)
%REM
    A simple move attendees function if the relationship between courses and attendees uses 
    (non-response) key based documents
%END REM
    On Error Goto errHandle
    Dim session As New notesSession
    Dim dcAttendees As notesDocumentCollection
    Dim docAttendee As notesDocument
    Dim iAvailablePlaces As Integer
    Dim bMoved As Boolean
    ' a view that lists attendees by Course ID
    Dim vwAttendeesByCourseID As notesView
    Dim db As notesDatabase

    If Not (docCourseFrom Is Nothing Or docCourseTo Is Nothing) Then        
        iAvailablePlaces = docCourseTo.availablePlaces(0)
        If 0 < iAvailablePlaces Then
            Set db = session.CurrentDatabase
            ' do a lookup of all attendees based on the CourseFrom document course id
            Set vwAttendeesByCourseID = db.GetView("(LkupAllAttendeesByCourseID)")
            ' this is the collection of all attendees under the CourseFrom document
            Set dcAttendees = vwAttendeesbyCourseID.GetAllDocumentsByKey(docCourseFrom.CourseID(0), True)
            bMoved = False
            Set docAttendee = dcAttendees.GetFirstDocument
            ' While there are attendee documents to process and there are available places to goto
            While Not docAttendee Is Nothing And 0 < iAvailablePlaces
                ' if the attendee's status is "Wait Listed" then move them
                If Ucase(Trim(docAttendee.Status(0)))= "WAIT LISTED" Then
                    ' Update the course ID for the Attendee
                    docAttendee.CourseID = docCourseTo.CourseID(0)
                    If docAttendee.Save(True,True) Then
                        ' decrement the available places
                        iAvailablePlaces = iAvailablePlaces - 1
                        bMoved = True
                    End If
                End If
                Set docAttendee = dcAttendees.GetNextDocument(docAttendee)
            Wend
            If bMoved Then
                ' available places may be >= 0. Just update the available places so you don't over book the course
                docCourseTo.availablePlaces = iAvailablePlaces
                Call docCourseTo.Save(True,False)
            End If
        End If
    End If  
    Exit Sub
errHandle:
    Messagebox Lsi_info(2) + " - " + Str(Err) + " : " + Error(Err) + ", at line " + Str(Erl)
    Exit Sub
End Sub
Sub-moveAttendeeSkeybase(docCourseFrom As notesDocument,docCourseTo As notesDocument)
%雷姆
如果课程和与会者之间的关系使用
(非响应)基于密钥的文档
%终止REM
关于错误转到错误句柄
将会话设置为新便笺会话
Dim DCAttenders As notes文档集合
Dim docAttendee As notes文档
Dim iAvailablePlaces为整数
模糊b移动为布尔值
'按课程ID列出与会者的视图
将与会者分组为备注视图
Dim db As notesDatabase
如果没有(docCourseFrom