Alphabetically Sort WebForm Views

Customisation Title Alphabetically Sort WebForm Views
Purpose of Customisation Order the Form Views attached to a template alphabetically
Author Greg Griffiths
Date of Customisation 08 May 2003
Covers Livelink Livelink 9.0.0.1
Livelink Modules Form
Affected Templates \module\form\html\formviewselection.html
\module\formwfpaint\html\addform.html
Customisation Format HTML
Download Here Download as a ZIP file.

When working with WebForms, you have to select the approriate view that you wish to use in several locations - a workflow form step, when creating a Form object and for the Workflow Status view - in all of these, the order of the available WebForm Views is the order that they were added to Livelink, this customisation reorders them alphabetically.

As there are three distinct locations where the ordering needs to be changes, we need to amend three different templates to achieve this. We shall begin with FormViewSelection.html, which is used when we create a Form within the Livelink workspaces :

<SELECT NAME="LL_FormView">
`%L$HTMLPkg.FmtPopupItems( views.Keys, value, TRUE, views.Vals )`
</SELECT>
<script>
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
if (document.CreateForm)
{
    theDD=document.CreateForm.LL_FormView;
}
// if we are looking at the properties of the form.
else
{
    theDD=document.infoFrm.LL_FormView;
}
// 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)
    {
        ds=count;
    }
}
// sort them
arr_optionsText.sort();
// 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])
        {
            arr_optionsValue[i]=theDD.options[j].value;
        }
    }
}
// empty the dd
theDD.options.length=0;
// 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);
    }
    else
    {
        theDD.options[i]= new Option(arr_optionsText[i],arr_optionsValue[i]);
    }
}
</script>

</TD>

This results in the following change to the screen :

Current View New View
Screenshot Screenshot

This change will also apply when you try and change the WebForm View via the Specific option of the Form Object, as shown below :

Current View New View
Screenshot Screenshot

The next template that we need to amend is the one that is used when setting the default WebForm View for a Workflow Map. This is the WebForm View that is shown when you click on the Form in the Form tab of the Workflow Status.

function deleteForm()
{
    if ( confirm( '`%L[WebFormWF_HTMLLabel.AreYouSureYouWantToDeleteThisForm]`' ) )
    {
        document.AddForm.xAction.value='Delete';
        document.AddForm.submit();
    }
}
function resetDD()
{
    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
    // populate the array
    for (count=0;count<document.AddForm.ViewName.options.length;count++)
    {
        arr_optionsText[count] = document.AddForm.ViewName.options[count].text;
        // if this is the selected one
        if (document.AddForm.ViewName.options[count].defaultSelected)
        {
            ds=count;
        }
    }
    // sort them
    arr_optionsText.sort();
    // get the correct values
    for (i=0;i<arr_optionsText.length;i++)
    {
        for (j=0;j<document.AddForm.ViewName.options.length;j++)
        {
            if (document.AddForm.ViewName.options[j].text==arr_optionsText[i])
            {
                arr_optionsValue[i]=document.AddForm.ViewName.options[j].value;
            }
        }
    }
    // empty the dd
    document.AddForm.ViewName.options.length=0;
    // repopulate the list
    for (i=0;i<arr_optionsText.length;i++)
    {
        // if the selected element
        if (i==ds)
        {
            document.AddForm.ViewName.options[i]= new Option(arr_optionsText[i],arr_optionsValue[i],true,true);
        }
        else
        {
            document.AddForm.ViewName.options[i]= new Option(arr_optionsText[i],arr_optionsValue[i]);
        }
    }
}

</SCRIPT>
<BODY BGCOLOR="#FFFFFF" BACKGROUND="`imgPrefix`pattern.gif" ONLOAD="onLoadFunctionMenu( '`imgPrefix`actions.gif', '`imgPrefix`menuwait.gif' );onLoadFunction();resetDD();">

The following screenshots show this customisation in action :

Current View New View
Screenshot Screenshot

This template is also the template that is used when we modify the WebForm view used for the Workflow Status Form in a workflow as shown in the screenshots below :

Current View New View
   

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