0

我在“批准人”数据库​​中有一个名为批准人的表格。

该表单有两个可编辑的文本字段:OfficeGroup。它还有一个对话列表字段super1

上级对话列表字段应显示基于办公室和组过滤的人员详细信息:

如果office = TSP & group = HR来自批准者表单,则 shud 基于这些字段组“和”办公室“使用另一个数据库“TSP_Staff”的“员工信息”视图过滤员工,并显示在superior1中。

但它并没有被我过滤掉。:(

我是这项技术的新手,所以我很困惑,没有人可以帮助我。这是我使用的脚本:

对于superior1字段:

Sub Entering(Source As Field)
    Dim s As New NotesSession
    Dim db As NotesDatabase
    Dim view As NotesView
    Dim uidoc As NotesUIDocument
    Dim doc As Notesdocument
    Dim work As  New NotesUIWorkspace
    Dim workspace As  New NotesUIWorkspace
    Dim sname As String
    Dim consr As String
    Dim cview As notesview

    Set db = s.CurrentDatabase
    Set uidoc = work.CurrentDocument
    Set uidocs = workspace.currentdocument  
    Set cview = db.getview("(Application)")

    'etype = uidoc.FieldGetText("Office") 
    'ftype = uidoc.FieldGetText("Group") 

    etype = "TSP"
    ftype = "TSP1-G"

    If(etype <> "" And ftype <> "")  Then
        Call filter  
    End If

    Set view = db.getview("(x_search_staff)")
    Set doc = view.GetDocumentByKey (uidoc.fieldgettext("Superior1"),True)

    If doc Is Nothing Then
        Msgbox "There is no previous transaction please select new trasaction.", 16, "Information"
        Call uidoc.FieldClear("Superior1")
        Call uidoc.gotofield ("Group")
        Call uidoc.gotofield ("Office")
        continue = False
        Exit Sub
    End If

    Call uidoc.Refresh 
End Sub

从脚本库...

Sub filter
    Dim s As New notessession
    Dim w As New notesuiworkspace
    Dim uidoc As notesuidocument
    Dim doc As notesdocument, newdoc As notesdocument, d As notesdocument, dd As notesdocument
    Dim doc1 As NotesDocument, newdoc1 As NotesDocument
    Dim dc As notesdocumentcollection
    Dim bc As notesdocumentcollection
    Dim view As notesview, v As notesview
    Dim db As notesdatabase
    Dim nextdoc As NotesDocument
    Dim cview As notesview
    Dim cnview As NotesView
    Dim get_db As New notesdatabase(gsserver2, gspath2 & "Master\TSP_Staff.nsf")

    Set db = s.currentdatabase

    Set view = get_db.getview("(Staff Info)")
    Set cview = db.getview("(x_search_staff)")
    Set cnview = db.getview("(x_superior)")
    Set uidoc=w.CurrentDocument 

    'To delet searched previous datas from form2 ----------------------------------------
    Print "Please wait ..."

    key = "Approver2"
    Set v = db.getview("(x_delete_2)")
    Set dc = v.GetAlldocumentsByKey(key,True)
    'Set bc = v.GetAlldocumentsByKey(key,True)

    'Call bc.RemoveAll(True)
    Call dc.RemoveAll(True)
    Call cview.Refresh

    Call view.Refresh
    Call cnview.Refresh
    Call v.Refresh

    'To start searching process based on Superior1 --------------------------------------

    'f1= uidoc.FieldGetText("Office") 
    f1= uidoc.FieldGetText("Group") 
    'f1 = "TSP1-G"

    Set dc = view.getalldocumentsbykey(f1, True) 
    'Set bc = view.getalldocumentsbykey(f2, True)

    For b =1 To dc.count
        Set doc = dc.getnthdocument(b)
        Set newdoc = doc.copytodatabase(db)
        'For c =1 To bc.count
        'Set doc1 = bc.getnthdocument(b)
        'Set newdoc1 = doc.copytodatabase(db)


        If doc.form(0) = "Approver" Then
        'If doc1.form(0) = "Approver" Then
            newdoc.form = "Approver2"
            'newdoc1.form = "Approver2"
            'End If 

        End If 
        newdoc.save True, True 
         ' Next
         'newdoc.save True, True
         'Next

        Call w.viewrefresh
        Call cview.Refresh
        Call v.Refresh
        Call cnview.Refresh
        Call view.Refresh

        Print "Process Completed....."
End Sub

如果你有另一种方法来满足这个要求,那就是一步一步地去做……否则……检查 ma 脚本是否有错误……希望你能帮助我:(今天这个任务的截止日期……

4

2 回答 2

0

我不确定通过从数据库中删除文档来过滤视图中显示的文档有多聪明:)

我的建议是首先正确发布代码。这简直无法阅读。

如何在对话框列表中仅显示文档子集?

在您的表单上创建一个隐藏字段(您将使用您的代码使用您希望在列表中显示的值填充它)。然后,在您的对话框列表字段属性的第二个选项卡上,将选项选项设置为“使用公式进行选择”并将其设置为隐藏字段名称。

询问您是否需要更多帮助...

于 2011-02-28T12:52:11.987 回答
0

你的代码很难理解,但如果我理解你的意图和filter函数的一部分(它甚至可以编译吗?)你可以在superior1的“使用公式进行选择”部分中用这个基于@dblookup的公式替换所有代码特性:

@dblookup("":"ReCache";"ServerName":"foo\Master\TSP_Staff.nsf";"(Staff Info)";Group;NameOfInterestingField);

如果视图包含重复值,您可能需要在其周围添加@sort和/或@unique ,并且如果某些组应该导致空列表,您可能需要添加关键字[FAILSILENT] 。

一个更简单的方法是配置superior1使用视图对话框进行选择

于 2011-05-09T17:59:54.023 回答