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

 

Text box prompt, to restrict the values in the given range, along with that shou

Started by xyz, 25 Apr 2016 11:01:08 AM

Previous topic - Next topic

xyz

Hi Gurus,

I am using Cognos 10.2.2 and relation model and data source is sql server. I have a requirement to use text box prompt mandatory filter, where it should only allow users to enter the number between the range of 3 to 52 and it has a default value, if the user enters any number out of the given range then the Finish button should disable. We have property of allow number for text box prompt, which will only allow the user to enter the number and the Finish button will get disabled, if the user enters any alphanumeric.

Can we have the same behavior of 'Finish' button gets disabled, if the user enters the numbers out of the valid range of 3 to 52.
I guess, we only have the option to achieve my requirement is through java script.

Can some one please help me the java script on the same.


Thanks & Regards,
XYZ

navissar

OK. The verification that you describe isn't difficult to write using Prompt API - the setValidator() sample here (https://www.ibm.com/support/knowledgecenter/SSEP7J_10.2.1/com.ibm.swg.ba.cognos.ug_cr_rptstd.10.2.1.doc/r_prmpt_api_cognos_prompt_control_setValidator.html%23cognos.prompt.control.setValidator) is that much more complicated so you can use that as a basis.
HOWEVER. This is a relatively small and concise range. Why not just use a drop down?

xyz

Hi Nimrod,

Thank you very much. As always your help is much appreciated.

I am not good at java script. But I found a java script from net, but, it is not working as expected in the sense the Finish button is not getting disabled, if I am entering the numbers below 3 or above 52. There is some small piece of code I guess, I am missing in the java script, can you please help me on the that. Below is my java script.

<script language="javascript">

var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined) { fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );}

//alert("I am in Text box prompt");

var var1= fW._textEditBoxNoOfSprnts;

//alert(var1);
function load()
{

if ((var1.value=="") || (var1.value==null))
{

alert("Please enter Number");
return false;
}


else if(var1.value < 3 || var1.value > 52)
{

textBox.setValidator(
   function (value) {
      var result = false;
      if (value && value.length > 0) {
         var sValue = value[0]['use'];
         var rePostalCodeFormat = new RegExp( "[3-52] ?[3-52]", "26" );
         if ( rePostalCodeFormat.test(sValue ) ) {
            result=true;
         }
      }
      return result;
   }
);
//alert('Please enter valid numbers between 3 to 52');
return false;

}

//promptButtonFinish();

}

load();

</script>

Thanks & Regards,
XYZ

navissar

Hi,
You still didn't answer my question - the simple solution would be a drop down with all the values.
If you are absolutely keen on using a text box then please don't use that script you put up here. Prompt API is so much simpler to use, will upgrade better and the setValidator() function will communicate with the finish button automatically. See the sample code in the link I gave you. Or follow this link - it has a post code validation sample which can be easily converted.
http://cognospaul.com/2012/11/05/cognos-prompt-api/

xyz

Hi Nimrod,

First of all Thanks for the reply

Thanks for the reply and link. I didn't ask my business analyst regarding the usage of value prompt instead of text box prompt. I guess, he might go with text box prompt though. I haven't tried the option of setvalidator in my javascript. Basically I am using the
below javasciprt code, because finally I am using the reports in Cognos Workspace.

var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined) { fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );}

I will give a try and let you know.


Thanks & Regards,
XYZ