#dominoforever | Product Ideas Portal

Welcome to the #dominoforever Product Ideas Forum! The place where you can submit product ideas and enhancement request. We encourage you to participate by voting on, commenting on, and creating new ideas. All new ideas will be evaluated by HCL Product Management & Engineering teams, and the next steps will be communicated. While not all submitted ideas will be executed upon, community feedback will play a key role in influencing which ideas are and when they will be implemented.

For more information and upcoming events around #dominoforever, please visit our Destination Domino Page

Sort DocumentCollection in LotusScript

From Ulf Grindstadt

We need the ability to sort Document collections, like NotesDocumentCollection.Sort(FieldNameArray)
  • Guest
  • Jul 19 2018
  • Shipped
  • Attach files
  • Guest commented
    1 Apr, 2022 08:43pm

    Sorting collections is not in the ideology of the platform, and it will be long anyway. I am surprised, why to use crutches if one can prepare views and quickly take correctly sorted data from there? With proper design, there will be few such views.

  • Guest commented
    1 Apr, 2022 06:11pm

    What about creating the QueryResultsProcessor on a local database (e.g. names.nsf), feeding it with remote document collections or view entry collections and then processing the result of the executeToJSON call? Haven’t tested it, but I would think that the QRP input set can be remote. It’s just the QueryResultsProcessor instance that needs to be created on a local database.

    But for the simple task of sorting a DocumentCollection, I would use the intersect/maintainOrder solution, at least when I had a view that contains the required sorting.

    Karsten Lehmann, Mindoo GmbH

  • Guest commented
    1 Apr, 2022 04:29pm

    @Lothar - (Notes)QueryResultsProcessor does not work client/server. You must run it on a local database and execute the containing code using RunOnServer. QRP provides both JSON and view output, where JSON is a stream of sorted results.

  • Guest commented
    28 Jan, 2022 11:00am

    Hi Thomas,

    I'm sorry to again disagree to the "Shipped" status:

    So I tried how far I can get here, but had to find that we still cannot make use of that class on a server-based database:

    while I can get it to work on my local machine, as soon as my test agent tries to execute

    >> Set qrp = thisDb.CreateQueryResultsProcessor()

    I get a message telling me that this method is unavailable.

    Both client and server are 12.0.1, ODS is 53 (on server) and 52 (local replica).

    Finally let me add: while I personally never really had the need to sort my docCollections, others apparently are missing that feature. But if I had, using a qrp at least currently wouldn't get me a "sorted" in-memory docCollection which then by looping it would give me my docs in the expected "order".

    Regards, Lothar (Lothar.Mueller@edcom.de)

  • Admin
    Thomas Hampel commented
    20 Jan, 2022 09:51pm

    This can be done with the new QueryResultProcessor class in V12 , for details see this: https://help.hcltechsw.com/dom_designer/12.0.0/basic/H_NOTESQUERYRESULTSPROCESSOR_CLASS.html

  • Guest commented
    18 Sep, 2020 04:53am

    If I recall right, techtarget solution is limited to dc's of same database. As it is just one line of code to fix this (Set db = s.currentdatabase versus set db = dc.'WhatEverItTakesHere' ) this should be corrected when implementing.

  • Guest commented
    17 Sep, 2020 01:31pm

    In plan for v12

  • Guest commented
    10 Jan, 2020 01:51am

    Use case: User clicks a "report" button and enters a date range and selects customer number, part number or location.  A db.search returns the matching documents in a collection.  The desired field values are then written to Excel for display.  It looks clunky to use Excel's sort after the rows are written. 

    The SearchDomino solution works  fine.  Nevertheless, it would be nice if it was built in.

  • Guest commented
    10 Jan, 2020 12:21am

    Basic Document Collection Sort function:  see https://searchdomino.techtarget.com/tip/LotusScript-sorts-a-Lotus-Notes-document-collection

  • Guest commented
    21 Feb, 2019 10:53pm

    Please look at maintainOrder in 10.0.1 on (Notes)ViewEntryCollection intersect and subtract functions.  If you intersect your NotesDocumentCollection with a sorted NotesViewEntryCollection, you get sorted results.

    We'll do more, but I wanted to make sure people knew about it.  It's available in 10.0.1.


  • Guest commented
    9 Feb, 2019 12:32am

    I have been developing under Lotus since 2001 fulltime, and never needed to sort collections.
    The need to sort collections usually speaks of improperly projected applications.

  • Guest commented
    4 Feb, 2019 08:32am

    Domino 10.0.1 provides a solution with ViewEntryCollection.intersect(DocumentCollection dc, boolean maintainOrder);

    That way, you can use a sorted view (or sort it in code with View.resortView(String column)), get a ViewEntryCollection via View.getAllEntries() and reduce it to only contain entries of your document collection.

  • Guest commented
    28 Dec, 2018 08:55pm

    Please add this.  It's somewhat embarrassing that we don't have a sort method.  I will add to Ulf's suggestion, by including another argument:


    NotesDocumentCollection.Sort(FieldNameArray, Ascending or Descending)

  • Guest commented
    14 Nov, 2018 03:46pm

    Testing DQL via node.js, I also realized that we need sorting for DQL

  • Guest commented
    1 Aug, 2018 07:17am

    +1 for "add sorting to DQL"

  • Guest commented
    27 Jul, 2018 11:45pm

    Or add sorting to DQL.