首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >过滤过程脚本库

过滤过程脚本库
EN

Stack Overflow用户
提问于 2011-02-28 01:57:14
回答 2查看 557关注 0票数 0

我在" Approver“db中有一个名为Approver的表单。

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

superior1对话框列表字段应该显示根据office &group过滤的人员详细信息:

如果批准者表单中的office = TSP & group = HR,然后shud根据这些字段组“&”office过滤其他数据库"TSP_Staff“的"Staff info”视图,并显示在superior1中。

但对我来说没有被过滤。:(

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

对于superior1字段:

代码语言:javascript
运行
复制
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

从脚本库..。

代码语言:javascript
运行
复制
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

如果你有另一种方法来满足这个要求,那么你可以逐步的去做.否则..。找出错误脚本..。希望你能帮我:(今天这个任务的到期日.

EN

回答 2

Stack Overflow用户

发布于 2011-02-28 12:52:11

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

我的建议是首先正确地发布代码。这简直是不可读的。

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

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

如果你需要更多的帮助..。

票数 0
EN

Stack Overflow用户

发布于 2011-05-09 17:59:54

您的代码很难理解,但是如果我理解您的意图和filter函数的部分(它甚至编译了吗?)您可以在@dblookupsuperior1属性的“为选择使用公式”部分中使用此superior1公式替换所有代码:

代码语言:javascript
运行
复制
@dblookup("":"ReCache";"ServerName":"foo\Master\TSP_Staff.nsf";"(Staff Info)";Group;NameOfInterestingField);

如果视图包含重复的值,则可能希望在其周围添加一个@排序和/或@唯一;如果某些组应该导致空列表,则可能希望添加关键字FAILSILENT。

一个更简单的方法可能是将superior1配置为选择使用“视图”对话框

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5137525

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档