• Sort Options

    By K Alford 2 decades ago

    Hi Stefan,



    I've been playing around with your Letter Engine and find that it is a great tool that is very simple to set up and use. (no problems getting the labels to work). However I was wondering if you could add in some sort of functionality to the template definitions that would give the option to choose the fields to sort the output by and whether or not the sort-fields are sorted in ascending or descending order.



    Your consideration for this would be greatly appreciated.



    Thanks,



    K. Alford.

    • follow-up on sort.

      By K Alford 2 decades ago

      I did some searching and found this sort code (as modified) by Per Henrik Lausten which when added into the letter agent will accomplish the basic sorting requirements on the document collection.



      http://per.lausten.dk/domino/sortNotesDocumentCollection.html



      I inserted his function into your "Correspondence\Letter|ComposeLetter" agent within my target database, added the "dim" line for Fieldnames (0 to 1) as String and then called from within the initialization section so that dc (original document collection) is replaced with the sorted collection before being pass through to the word templates.



      It's a crude and hasitly thrown-together workaround. . .but it worked like a charm.

      • Sorting the data source

        By Stefan Johannsen 2 decades ago

        Very well.

        I shouldn't sort the data source file (this is the eseast way), because the next release saves the created serial letters into datasource (optionaly). Thus I have to sort the document collection.

        I have a code to sort the collection useing the document position of a view. But the performance is the central issue.



        While I'm writing this, I've got an idea….

        I will try to save the document univeral ID in a column to indicate the documents in a sorted worksheet.

        Than sort the worksheet befor saving the data source file - it is faster than run through the document collection:


            Const xlAscending = 1<br/>
            Const xlGuess = 0<br/>
            Const xlSortTextAsNumbers = 1<br/>
            Const xlTopToBottom = 1<br/>
            Call sheet.Range(columns, row).Sort(sheet.Range(columns, row).Cells(1), _ ' Key1<br/>
            xlAscending, _ ' Order1 = xlAscending<br/>
            sheet.Range(columns, row).Cells(2), _ ' Key2<br/>
            , _ ' Type<br/>
            xlAscending, _ ' Order2 = xlAscending<br/>
            sheet.Range(columns, row).Cells(3), _ ' Key3<br/>
            xlAscending, _ ' Order3 = xlAscending<br/>
            xlGuess, _ ' Header = xlNo<br/>
            1, _ ' OrderCustom<br/>
            False, _ ' MatchCase<br/>
            xlTopToBottom, _ ' Orientation = xSortRows<br/>
            , _ ' SortMethod = xlPinYin<br/>
            xlSortTextAsNumbers)    ' DataOption1 = xlSortNormal<br/>
        



        And finaly I use the position of the record set in the data source to get the correct letter in the Documents-Object of the word instance.

        I think that's easier.

        • configure sort

          By Stefan Johannsen 2 decades ago

          Of course, the user should have the possibility to specify the fields which will used for sorting and the order of sorting.



          Currently, I developing a dialog form to define the field formulas of the Field Mapping Table. This dialog may contains the sort options.