Lotus notes 保存的文档的序列号

Lotus notes 保存的文档的序列号,lotus-notes,Lotus Notes,我在表单的querysave事件中使用以下脚本。逻辑是当我保存表单时,序列应该以两列的形式显示在视图中。比如115-在一列中,序列00001,00002。。。在第二栏。前两个文档保存时没有任何问题。当我保存尝试保存第三个或更多文档时,它仅在保存之后每次显示00002。我无法确定是什么错误。有人能帮忙吗 Sub Querysave(Source As Notesuidocument, Continue As Variant) Dim SESS As New NotesSessi

我在表单的querysave事件中使用以下脚本。逻辑是当我保存表单时,序列应该以两列的形式显示在视图中。比如115-在一列中,序列00001,00002。。。在第二栏。前两个文档保存时没有任何问题。当我保存尝试保存第三个或更多文档时,它仅在保存之后每次显示00002。我无法确定是什么错误。有人能帮忙吗

Sub Querysave(Source As Notesuidocument, Continue As Variant)
    Dim SESS       As New NotesSession
    Dim w          As New NotesUIWorkspace
    Dim uidoc      As NotesUIdocument
    Dim Doc        As NotesDocument
    Dim RefView    As NotesView
    Dim DB         As NotesDatabase
    Dim RefDoc     As NotesDocument
    Set DB      =  SESS.CurrentDatabase
    Set uidoc   =  w.CurrentDocument
    Set Doc     =  uidoc.Document
    Set RefView =  DB.GetView("System\AutoNo")

    Dim approvedcnt As Integer
    approvedcnt = Cint(source.fieldgettext("appcnt"))

    If uidoc.EditMode = True Then 
        Financial_Year =  Clng(Right$(Cstr(Year(Now)),3)) + 104
        If Month(Now) >= 4 Then Financial_Year = Financial_Year + 1
        DocKey     =  Cstr(Financial_Year)& "-"
        New_No      =  0
        Set RefDoc  =  RefView.GetDocumentByKey(DocKey , True)
    If Not(RefDoc Is Nothing) Then New_No = Clng(Right$(RefDoc.SETTLEMENT_NO(0),5))
        New_No      =  New_No + 1
        autono      =  DocKey & "-" & Right$("00000" & Cstr(New_No) ,5)
        Application ="ST"
        Latest_No = Application + autono
        Doc.SETTLEMENT_NO = Latest_No
        Doc.FinFlag="Finish"
    Call SESS.SetEnvironmentVar("ENV_ST_NO",Right$("00000" & Cstr(DefNo&) ,5))
        'Call uidoc.FieldSetText("SETTLEMENT_NO",Latest_No)

        Call uidoc.Refresh
        Else
        Exit Sub
    End If

    get_ex_rate
    get_cv_local


    Call uidoc.FieldSetText("Flag1", "A")

    If approvedcnt = 12 And uidoc.FieldGetText("STATUS") = "APPROVE" Then
        Call uidoc.fieldsettext("Flag2", "B")
    End If

    Dim answer2 As Integer

    answer2% = Msgbox("Do you want to save this document?", 1, "Save")
    If answer2 = 1 Then 
        Print "Saving"
    End If  
    If answer2 = 2 Then
        continue=False
        Exit Sub
    End If

    uidoc.Refresh
    uidoc.close

End Sub

我想您对GetDocumentByKey的调用可能是获取了错误的文档,或者不是序列中的下一个文档。确保视图已正确排序,并且在调用GetDocumentByKey之前,可能会调用视图上的refresh方法

我也调用了刷新方法。第三次当我试图保存它时,给出了相同的前一个数字。我真的很无助。我已经在这上面花了很多时间:你可以打开DebugLotusScript,在你一步一步地完成代码的时候观察值。查看RefDoc是实际文档还是返回为空文档。还要确保AutoNo视图已正确排序,并打开它以确保在第二次保存后显示00002。