Search code examples
lotus-dominolotusscriptlotus-formula

How to obtain value of Notes count column


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


Solution

  • You need to use NotesViewNavigator and NotesViewEntry- objects.

    NotesDocument always represent a DOCUMENT in the view (the single line), but never the category itself. That's why you need NotesViewentries: they can also represent category- lines.

    To get a list will all documents that are "duplicate" you could do something like this:

    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
    

    Unfortunately totals- columns cannot be sorted by their total value nor filtered. So you really NEED to go the "code"- way.