If you are unable to create a new account, please email support@bspsoftware.com

 

TextBox Prompt parameter contains nbsp; - Value was set by JavaScript

Started by JohnBarleyCorn, 30 Apr 2014 01:42:13 PM

Previous topic - Next topic

JohnBarleyCorn

The short version of this problem is: A multi-word string (ex. MID SOUTH) used as the value of a parameter being derived by JavaScript function on Prompt Page includes  , and causes error when attempt is made to use the parameter in a detail filter.  In other words, MID SOUTH is being passed via the parameter as MID SOUTH.  And Report Studio engine errors out stating that a non-valid member of a hierarchy has been presented to it.  I know this because when the error occurs I choose to "View > Source" in the browser, and I find that the   is placed between the words "MID" and "SOUTH".

Background Story:
Prompt page contains a DropDown List prompt named regionprompt.  Its list of values is initially populated by a query.  There is also a TextBox prompt on the page named hiddentextbox, and it's "value" is intended to be the regionprompt.options[regionprompt.selectedIndex].text from the DropDown List.  JavaScript is used in a custom "Finish" button to set the "value" of the TextBox prompt.  In other words, user selects something in the DropDownList, they click "Finish" and the selected value of DropDownList is used to populate the "value" of the TextBox Prompt.  This works fine.

The parameter name used in the TextBox prompt's properties is "pMyTextBoxText".  This parameter is used in the main report query as part of its Detail Filter.  I'm using a #prompt macro in the filter to retrieve the value of "pMyTextBoxText".  In the #prompt macro the value of "pMyTextBoxText" is joined with pre-text to create a MUN.  The detail filter is written as:

[QBR Reporting].[Resource].[Resource] =#prompt('pMyTextBoxText','token','','[QBR Reporting].[Resource].[Resource]->:[TM].[Resource].[Resource].[@MEMBER].[ALL DEPARTMENTS^ RESOURCING^STAFFING^','',']')#

In the JavaScript I have tried using hiddentextbox.replace(/ g,"");, but I don't think the   is present at this point.  It is probably added when the report page is being rendered.

Can someone recommend a way to eliminate the   that is being added?

This is the JavaScript I am using:

<script LANGUAGE="JavaScript" type="text/javascript">
//<!–
function assignParamValue()
{
// get the reference to the Cognos form and prompt objects
var fw = getFormWarpRequest();
var regionprompt=fw._oLstChoicesregionprompt;
var hiddenTextBoxCtrl = fw._textEditBoxhiddenTextBoxCtrl;
var the_value;

// check value of regions prompt dropdown list box and make a decision about value to use
// assign dropdown list box selected value to var the_value
if
(regionprompt.options[regionprompt.selectedIndex].text != 'Region')
    {the_value=regionprompt.options[regionprompt.selectedIndex].text.replace(/&nbsp;/g,""); }
else
{the_value='NORTHEAST'; }
//try to replace nbsp if it is in the_value
the_value =  the_value.replace(/&nbsp;/g,"");
//set textbox control text equal to value of the_value
hiddenTextBoxCtrl.value = the_value;
//try to replace nbsp if it is in the hiddenTextBoxCtrl.value
hiddenTextBoxCtrl.value = hiddenTextBoxCtrl.value.replace(/&nbsp;/g,"");

promptButtonFinish();

}
//–>
</script>


Best regards,
-Kirk

JohnBarleyCorn

I did come up with a different approach to using JavaScript to manage the prompt page and avoid the &nbsp issue.

LFC

Hey Krik,
If you dont mind can you post how you solved the issue? somebody down the line can benefit from it.

Thanks