Skip to Main Content
HCL Domino 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)
  • Attach files
      Drop here to upload
    • Guest
      Reply
      |
      Jul 26, 2023

      When using NotesQueryResultsProcessor

      I get the error MyTempView not declared Set myview = qrp.executeToView(“MyTempView”, 2)

      What am I missing?

    • Guest
      Reply
      |
      Apr 1, 2022

      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
      Reply
      |
      Apr 1, 2022

      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
      Reply
      |
      Apr 1, 2022

      @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
      Reply
      |
      Jan 28, 2022

      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
      Reply
      |
      Jan 20, 2022

      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
      Reply
      |
      Sep 18, 2020

      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
      Reply
      |
      Sep 17, 2020

      In plan for v12

    • Guest
      Reply
      |
      Jan 10, 2020

      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
      Reply
      |
      Jan 10, 2020

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

    • Guest
      Reply
      |
      Feb 21, 2019

      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.


      https://www.ibm.com/support/knowledgecenter/SSVRGU_10.0.1/basic/H_INTERSECT_METHOD_VEC_JAVA.html
      https://www.ibm.com/support/knowledgecenter/SSVRGU_10.0.1/basic/H_SUBTRACT_METHOD_VEC_JAVA.html

    • Guest
      Reply
      |
      Feb 9, 2019

      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
      Reply
      |
      Feb 4, 2019

      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
      Reply
      |
      Dec 28, 2018

      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
      Reply
      |
      Nov 14, 2018

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

    • Guest
      Reply
      |
      Aug 1, 2018

      +1 for "add sorting to DQL"

    • Guest
      Reply
      |
      Jul 27, 2018

      Or add sorting to DQL.