过滤进程脚本库

时间:2011-02-28 01:57:15

标签: lotus-notes lotusscript

我在“审批人”数据库​​中有一个名为审批者的表单。

表单有两个可编辑的文本字段: Office 。它还有一个对话框列表字段 superior1

superior1 对话框列表字段应显示根据office& amp;组:

如果office = TSP & group = HR来自审批者表单,则根据这些字段对工作人员进行shud过滤“&”office“与另一个数据库”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

如果你有另外一种方式来满足这个要求,那么在逐步扫管笏中要做...或者... chk out ma script for errors ...希望你帮助我:(今天此任务的截止日期... < / p>

2 个答案:

答案 0 :(得分:0)

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

我的建议是先正确发布代码。这简直难以理解。

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

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

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

答案 1 :(得分:0)

您的代码非常难以理解,但如果我理解您的意图和filter函数的部分内容(甚至可以编译?),您可以用@dblookup为基础替换所有代码 superior1 属性的“使用公式选择”部分中的公式:

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

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

更简单的方法可以将 superior1 配置为use view dialog for choices