2011-02-28 28 views
0

我在「Approver」db中有一個名爲批准者的表單。篩選器進程腳本庫

形式有兩個可編輯的文本字段:辦公室集團。它還有一個對話框列表字段superior1

superior1對話框列表欄應該顯示員工的詳細信息過濾是以辦公室&組:

如果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 

如果你長了另一種方式在逐步笏這一要求temme到做...否則... chk出馬腳本的錯誤...希望你幫我:(今天到期日爲這項任務...

回答

0

我不知道它是多麼聰明是過濾文件在視圖中顯示刪除do從數據庫中取得的數據:)

我的建議是先正確地發佈代碼。這是根本不可讀的。

如何在對話框列表中只顯示文檔的子集?

在您的表單上創建一個隱藏字段(您將使用您的代碼填充您希望顯示在列表中的值)。 然後,在對話框列表字段屬性的第二個選項卡上,將選項選項設置爲「使用公式選擇」並將其設置爲隱藏字段名稱。

詢問是否需要更多的幫助......

+0

對不起..對於壞的發佈代碼... – user631457 2011-03-01 07:04:45

+0

沒有汗水。你有沒有解決這個問題? – 2011-03-05 21:42:28

0

你的代碼是非常難以遵循,但如果我理解你的意圖和filter功能部件(它甚至不能編譯?),你可以替換所有的在此@dblookup基於公式「使用公式的選擇」的superior1屬性部分代碼:

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

你可能要添加一個@sort和/或@unique周圍如果視圖包含重複值,而你可能要添加t他關鍵字[FAILSILENT]如果某些組應導致一個空的列表。

更簡單的方法可配置superior1use view dialog for choices