Decending by # of children in view?

I want my view to decend by catagories with most children to least children. I cannot use @DocChildren in a hidden column because it will not sort, any creative ideas?

My goal for example would be:

In a view where @UserName is a catagory, If I created 30 documents, and “Bill” created 4 documents, the view should list me above Bill.

Subject: Decending by # of doc children?

I’m pretty sure your best bet is to have a pseudo-view created by an agent, since the @DocChildren is not usable as a sortable value.

Subject: RE: Decending by # of doc children?

Thanks for the response Ben, but easier said then done. My searches are coming up with nothing on how to do this and its definitely new territory for me, is there a tutorial you can point me to?

Subject: RE: Decending by # of doc children?

Ben is suggesting that you write a scheduled agent in LotusScript to do something along the following lines (not tested!!!):

Sub Initialize

Dim ses as New NotesSession

Dim db as NotesDatabase

Dim dc as NotesDocumentCollection

Dim dcResp as NotesDocumentCollection

Dim doc as NotesDocument

Dim docResp as NotesDocument

Set db = ses.CUrrentDatabase

Set dc = db.UnprocessedDocuments

If dc.COunt > 0 Then

Set doc = dc.GetFirstDocument

Do WHile Not doc Is Nothing

doc.ReplaceItemValue “ChildDocumentCount”, 0

Set dcResp = doc.Responses

If dcResp.Count > 0 Then

Set docResp = dcResp.GetFirstDocument

Do WHile Not docResp Is Nothing

If docResp.HasItem(“$Conflict”) Then 'Not really a true response

Else

doc.ReplaceItemValue “ChildDocumentCount”, doc.ChildDocumentCount(0) + 1

End If

Set docResp = dcResp.GetNextDocument(docResp)

End If

doc.Save True, False 'Save the changes even if response count is zero

Set doc = dc.GetNextDocument(doc)

Loop

End If

End Sub

After the agent runs, each parent document will contain a field called ChildDocumentCount that can be used as a sortable field in the view.

THe agent will need to have modifications if you want to filter “parent” documents based on some kind of form or other value and that can be done either in the agent or as a criteria in the agent’s search parameter. You might also want to consider whether you want to count only direct descendants or any grandchild documents, etc. too (in which case, use recursion). Also, the agent could have some more smarts to not update the document if the response count is the same as is already in the document, but you get the general idea, right?

Subject: RE: Decending by # of doc children?

Yes thank you both!!!

Subject: RE: Decending by # of doc children?

Yes thank you both!!!