Alphabetically Sort Forms Views in the Workflow Step screen

Customisation Title Alphabetically Sort Forms Views in the Workflow Step screen
Purpose of Customisation Sort the WebForm views avavilable to be linked to a Workflow step alphabetically rather than in the order they were added to the system.
Author Greg Griffiths
Date of Customisation 12 September 2003
Covers Livelink Livelink 9
Livelink Modules FormWFPaint
Affected Templates \formwfpaint\html\tforms.html
Customisation Format HTML
Download Here Download as a ZIP file

This customisation sorts the HTML WebForm views that you have attached to a given template in alphabetical order when they are displayed in the screen that allows you to attach one or more WebForm Views to a Workflow Step.

The customisation is provided by the addition of a javascript sort function into the template. This function runs directly after the list of available WebForm views has been populated onto the form, and as such completes before the user has a chance to select one.

;if ( IsDefined( formData.Views ) )
    <SELECT NAME="FormView_`formData.ID`" SIZE="`Length( formData.Views.Keys )`" MULTIPLE ONCHANGE="markTaskEditDirty();">
    ;for ( i = 1; i <= Length( formData.Views.Keys ); i += 1 )
        ;if ( Type( value ) == ListType )
            ;checked = ( formData.Views.Vals[ i ] in value ) ? 'SELECTED' : ''
            ;checked = ( formData.Views.Vals[ i ] == value ) ? 'SELECTED' : ''
        <OPTION VALUE='`%LformData.Views.Vals[ i ]`' `checked`>`%LformData.Views.Keys[ i ]`</OPTION>
    <script language="javascript">
        var arr_optionsValue = new Array(); // array to hold the Value of the OPTIONS
        var arr_optionsText = new Array(); // array to hold the Text of the OPTIONS
        var ds; // Index of current selected Option
        var theDD; // reference to the Drop Down
        // if we are creating a form
        // populate the array
        for (count=0;count<theDD.options.length;count++)
            arr_optionsText[count] = theDD.options[count].text;
            // if this is the selected one
            if (theDD.options[count].defaultSelected)
        // sort them
        // get the correct values
        for (i=0;i<arr_optionsText.length;i++)
            for (j=0;j<theDD.options.length;j++)
                if (theDD.options[j].text==arr_optionsText[i])
        // empty the dd
        // repopulate the list
        for (i=0;i<arr_optionsText.length;i++)
            // if the selected element
            if (i==ds)
                theDD.options[i]= new Option(arr_optionsText[i],arr_optionsValue[i],true,true);
                theDD.options[i]= new Option(arr_optionsText[i],arr_optionsValue[i]);

This makes the selection of the required WebForm views significantly easier than is currently the case, as they are now in alphabetical order. A simplified version of the results of this customisation can be seen in the before and after screenshots below :

Screenshot Screenshot
Before After
Website Designed by Adservio Consulting      Bookmark and Share Valid HTML 4.01 Strict    Valid CSS!    Level A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0