How to automatically select a drop down list element when there is only one option

The following example shows how to automatically select a prompt element from Report Studio (drop down list) when is loaded by a unique element. Moreover, it removes the “Select an element...” label.

Resolving the problem:

1- Define the Report Studio’s component name. This name will be used later.

2- Create an HTML item below the component from step 1 with the following content:

var fW = (typeof getFormWarpRequest == "function" ?getFormWarpRequest() : document.forms["formWarpRequest"]);

if ( !fW || fW == undefined)

{ fW = ( formWarpRequest_THIS_ ?formWarpRequest_THIS_ : formWarpRequest_NS_ );

}

var obj = fW._oLstChoices_ComponentName;

if (obj .length == 3)

{

obj.remove(1);

obj.remove(0);

obj.removeAttribute('hasLabel');

}


3- Replace the “_ComponentName” with the one from step 1.

Note: It’s not recommended to use with non-mandatory parameters. If there is only one element on the component, Report Studio will automatically select it and we are going to be unable to let the parameter unselected.