Lotus notes 如何筛选选择文档以防止用户根据字段“选择不同的文档”;“地位”;

Lotus notes 如何筛选选择文档以防止用户根据字段“选择不同的文档”;“地位”;,lotus-notes,lotusscript,Lotus Notes,Lotusscript,在此之前,我问了这个问题,@Torsten Link建议我过滤文档,以防止用户选择不同的文档。基本上我有一个视图,在这个视图中,我有一个按错误状态排序的文档列表,我将其设置为PFStatus。因此,我有三种状态,分别是过时,被宠坏,和未找到。所以我想过滤,以便用户选择这三种状态中的任何一种,并且不能混淆 所以我尝试使用下面的代码进行过滤,但什么也没发生 Set doc = dc.GetFirstDocument() If (doc.PFStatus(0) = "Obsolete" And

在此之前,我问了这个问题,@Torsten Link建议我过滤文档,以防止用户选择不同的文档。基本上我有一个视图,在这个视图中,我有一个按错误状态排序的文档列表,我将其设置为PFStatus。因此,我有三种状态,分别是过时被宠坏,和未找到。所以我想过滤,以便用户选择这三种状态中的任何一种,并且不能混淆

所以我尝试使用下面的代码进行过滤,但什么也没发生

Set doc = dc.GetFirstDocument()
    If (doc.PFStatus(0) = "Obsolete" And doc.PFStatus(0) = "Spoilt" And doc.PFStatus(0) = "Not Found") Then
        Messagebox"Please choose either one Write Off selection!"
        Exit Sub
    Elseif (doc.PFStatus(0) = "Obsolete" And doc.PFStatus(0) = "Spoilt") Then
        Msgbox"Please choose only one Write Off selection!"
        Exit Sub
    Elseif (doc.PFStatus(0) = "Obsolete" And doc.PFStatus(0) = "Not Found") Then
        Msgbox"Please choose only one Write Off selection!"
        Exit Sub
    Elseif (doc.PFStatus(0) = "Spoilt" And doc.PFStatus(0) = "Not Found") Then
        Msgbox"Please choose only one Write Off selection!"
        Exit Sub
    Else
        'Some code...
    End If
那么,我如何筛选文档选择?我把代码放错地方了吗?任何帮助我都非常感激。谢谢。:)

更新问题

下面是我的视图名称“WriteOff”。我有一个按钮来创建新的批处理。所以我想尝试阻止用户创建一个错误状态混淆的批处理


PFStatus是多值字段吗?如果不是,则它的值不能超过1(除非以编程方式设置多个值)。还是复选框字段

我认为最好是不允许从视图中的多个类别中选择文档。看



IMHO状态字段不应由用户直接输入。您应该有按钮来引导用户执行某些功能,同时更改状态。

PFStatus是多值字段吗?如果不是,则它的值不能超过1(除非以编程方式设置多个值)。还是复选框字段

我认为最好是不允许从视图中的多个类别中选择文档。看



IMHO状态字段不应由用户直接输入。您应该有一些按钮来引导用户执行某些功能,同时更改状态。

我创建了一个关于如何执行此操作的示例

最好的方法不是将代码放入按钮,而是创建一个代理将代码放入。这样,在调试代码时就不需要刷新视图

将“代理列表选择”设置为触发器,目标=无

使用以下公式在视图中创建按钮(将“批处理”替换为您的代理名称):

下面是一个代理代码示例,说明如何检查所选文档中的pfstatus是否相同

Option Public
Option Declare

Sub Initialize
Dim col As NotesDocumentCollection
Dim doc As NotesDocument
Dim vwUI As NotesUIView
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim dbcurrent As NotesDatabase
Set dbCurrent = session.currentdatabase

'Use vwui.documents to keep documents selected if the agent runs. 
'Like this, a user can deselect a faulty document.
'Don't forget to deselect all docs at the end of your code  
Set vwui = ws.Currentview
Set col = vwui.Documents

'If a user did not 'select' a document (eg V marker before the docline), but merely positioned on a document,
'you need to create a single doc collection based on the caretnoteid (= id of selected document)
If col.count = 0 And vwui.caretnoteid <> "" Then
    Set doc = dbCurrent.Getdocumentbyid(vwui.caretnoteid)
    Set col = dbCurrent.createdocumentcollection()
    Call col.Adddocument(doc)
End If

'Get status from first document to get status to compare against
Dim statusRef As String
Set doc = col.getfirstdocument
If doc Is Nothing Then Exit Sub 'avoid error when no doc is selected
statusRef = doc.pfStatus(0)

'loop other selected documents to compare status
Set doc = col.getNextDocument(doc)
While Not doc Is Nothing
    If doc.pfStatus(0) <> statusRef Then
        'A document with another status is selected, so do not continue
        Msgbox"Please choose only one Write Off selection!"
        Exit sub
    End If
    Set doc = col.getNextDocument(doc)
Wend

'If code gets here, you can loop all documents again to do you batch processing
'Reset doc to first doc in selected collection
Set doc = col.getfirstdocument()
While Not doc Is Nothing
'... some code to run on current doc in the loop ...
    Set doc = col.getNextDocument(doc)
Wend


'Deselect documents at the end of your code
Call vwui.Deselectall()
End Sub
选项公共
选项声明
子初始化
Dim col As Notes文档集合
标注文档作为注释文档
将VUI设置为备注视图
将ws设置为新工作区
将会话设置为新便笺会话
Dim dbcurrent As NotesDatabase
设置dbCurrent=session.currentdatabase
'如果代理运行,请使用vwui.documents保持文档处于选中状态。
'像这样,用户可以取消选择有故障的文档。
'不要忘记在代码末尾取消选择所有文档
设置vwui=ws.Currentview
Set col=vwui.Documents
'如果用户没有'选择'文档(例如文档线前的V标记),而只是定位在文档上,
'您需要基于CaretNodeId(=所选文档的id)创建单个文档集合
如果col.count=0且vwui.caretnoteid为“”,则
Set doc=dbCurrent.Getdocumentbyid(vwui.CaretNodeId)
Set col=dbCurrent.createdocumentcollection()
调用col.Adddocument(doc)
如果结束
'从第一个文档获取状态以获取要比较的状态
Dim statusRef作为字符串
Set doc=col.getfirstdocument
如果单据为空,则退出子项“避免未选择单据时出错”
statusRef=文件状态pfStatus(0)
'循环其他选定文档以比较状态
Set doc=col.getNextDocument(doc)
而不是医生什么都不是
如果文件pfStatus(0)statusRef,则
'已选择另一状态的文档,因此不要继续
Msgbox“请仅选择一个核销选项!”
出口接头
如果结束
Set doc=col.getNextDocument(doc)
温德
'如果代码到达这里,您可以再次循环所有文档以进行批处理
'将单据重置为所选集合中的第一张单据
Set doc=col.getfirstdocument()
而不是医生什么都不是
'... 要在循环中的当前文档上运行的某些代码。。。
Set doc=col.getNextDocument(doc)
温德
'取消选择代码末尾的文档
调用vwui.Deselectall()
端接头

我创建了一个关于如何执行此操作的示例

最好的方法不是将代码放入按钮,而是创建一个代理将代码放入。这样,在调试代码时就不需要刷新视图

将“代理列表选择”设置为触发器,目标=无

使用以下公式在视图中创建按钮(将“批处理”替换为您的代理名称):

下面是一个代理代码示例,说明如何检查所选文档中的pfstatus是否相同

Option Public
Option Declare

Sub Initialize
Dim col As NotesDocumentCollection
Dim doc As NotesDocument
Dim vwUI As NotesUIView
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim dbcurrent As NotesDatabase
Set dbCurrent = session.currentdatabase

'Use vwui.documents to keep documents selected if the agent runs. 
'Like this, a user can deselect a faulty document.
'Don't forget to deselect all docs at the end of your code  
Set vwui = ws.Currentview
Set col = vwui.Documents

'If a user did not 'select' a document (eg V marker before the docline), but merely positioned on a document,
'you need to create a single doc collection based on the caretnoteid (= id of selected document)
If col.count = 0 And vwui.caretnoteid <> "" Then
    Set doc = dbCurrent.Getdocumentbyid(vwui.caretnoteid)
    Set col = dbCurrent.createdocumentcollection()
    Call col.Adddocument(doc)
End If

'Get status from first document to get status to compare against
Dim statusRef As String
Set doc = col.getfirstdocument
If doc Is Nothing Then Exit Sub 'avoid error when no doc is selected
statusRef = doc.pfStatus(0)

'loop other selected documents to compare status
Set doc = col.getNextDocument(doc)
While Not doc Is Nothing
    If doc.pfStatus(0) <> statusRef Then
        'A document with another status is selected, so do not continue
        Msgbox"Please choose only one Write Off selection!"
        Exit sub
    End If
    Set doc = col.getNextDocument(doc)
Wend

'If code gets here, you can loop all documents again to do you batch processing
'Reset doc to first doc in selected collection
Set doc = col.getfirstdocument()
While Not doc Is Nothing
'... some code to run on current doc in the loop ...
    Set doc = col.getNextDocument(doc)
Wend


'Deselect documents at the end of your code
Call vwui.Deselectall()
End Sub
选项公共
选项声明
子初始化
Dim col As Notes文档集合
标注文档作为注释文档
将VUI设置为备注视图
将ws设置为新工作区
将会话设置为新便笺会话
Dim dbcurrent As NotesDatabase
设置dbCurrent=session.currentdatabase
'如果代理运行,请使用vwui.documents保持文档处于选中状态。
'像这样,用户可以取消选择有故障的文档。
'不要忘记在代码末尾取消选择所有文档
设置vwui=ws.Currentview
Set col=vwui.Documents
'如果用户没有'选择'文档(例如文档线前的V标记),而只是定位在文档上,
'您需要基于CaretNodeId(=所选文档的id)创建单个文档集合
如果col.count=0且vwui.caretnoteid为“”,则
Set doc=dbCurrent.Getdocumentbyid(vwui.CaretNodeId)
Set col=dbCurrent.createdocumentcollection()
调用col.Adddocument(doc)
如果结束
'从第一个文档获取状态以获取要比较的状态
Dim statusRef作为字符串
Set doc=col.getfirstdocument
如果单据为空,则退出子项“避免未选择单据时出错”
statusRef=文件状态pfStatus(0)
'循环其他选定文档以比较状态
Set doc=col.getNextDocument(doc)
而不是医生什么都不是