How to obtain value of Notes count column

时间:2015-11-12 12:07:48

标签: lotus-domino lotusscript lotus-formula

I have created a view that lists a count of the documents for contracts with certain Contractor ID's. One column is a count column, not categorized and hard coded with the formula of "1" and set to be a Total. Second column is ContractorID set to the field ContractorID and is Categorised. This is good so far but I wish to output the documents that have the same ContractorID. I have tried amending the View using a count on the "Count" column but without success. I also tried sorting the "Count" column in descending order to show at the top the documents where the same ContractorID is used but this doesn't appear to work either. Lastly, I tried using an agent to determine the value of the "Count" column but this only seemed to recognize the value of "1". How can I get the agent to determine if the value is not "1" or further filter the view to only show ones with count greater than "1"?

Here is an extract of the agent code;

Dim columnCount As Integer

Set requestDoc1 = viewContractors.GetFirstDocument
Do Until requestDoc1  Is Nothing
columnCount = requestDoc1.Columnvalues(0)
strContratorID = requestDoc1.getitemvalue("ContractorID")
    If columnCount <> 1 Then
    ..... Add strContratorID to list to output
    End if
Set requestDoc1 = viewContractors.Getnextdocument(requestDoc1)
Loop

Here is a screen dump of the view I wish to either further filter or the agent to manipulate

Contractor View Sample

2 个答案:

答案 0 :(得分:1)

您需要使用NotesViewNavigator和NotesViewEntry-对象。

NotesDocument始终表示视图中的DOCUMENT(单行),但从不表示类别本身。这就是你需要NotesViewentries的原因:它们也可以代表类别行。

要获得一份清单,所有文件都将重复#34;你可以这样做:

Dim viwNav As NotesViewNavigator
Dim veCat As NotesViewEntry

Set viwNav = viewContractors.Createviewnav()
Set veCat = viwNav.Getfirst()

While Not veCat Is Nothing
    If veCat.Columnvalues(0) > 0 Then
        strContratorID = veCat.Columnvalues(1)
        '- ..... Add strContratorID to list to output
    End If
    Set veCat = viwNav.Getnextcategory( veCat )
Wend

不幸的是,总数 - 列不能按其总值排序也不能过滤。所以你真的需要去#34;代码&#34; - 方式。

答案 1 :(得分:0)

1)在我看来,你应该改变两列的位置:

enter image description here

2)以下是您的代理人的改编代码:

    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim viewContractors As NotesView
    Dim viewNavigator As NotesViewNavigator
    Dim viewEntry As NotesViewEntry

    Dim contractorID As String
    Dim columnCount As Integer

    Set db = session.CurrentDataBase
    Set viewContractors = db.getView("Contractors")

    Set viewNavigator = viewContractors.CreateViewNav()

    Set viewEntry = viewNavigator.Getfirst()
    While Not(viewEntry Is Nothing)
        If viewEntry.Iscategory Then
            contractorID = viewEntry.Columnvalues(0)
            columnCount = viewEntry.Columnvalues(1)
        End If
        Set viewEntry = viewNavigator.Getnextcategory(viewEntry)
    Wend