COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: cogswell on 24 Feb 2011 01:56:12 PM

Title: Handling '%' if entered in a (numeric) Text Box Prompt
Post by: cogswell on 24 Feb 2011 01:56:12 PM
I have a text box prompt which I want to limit to numeric input. This can be done easily, but the associated parameter is actually used as a percentage.

In essence, I want Cognos to return '50' regardless of whether '50' or '50%' is entered. I can do a simple if-then-else logic to multiply paramvalue by 100 if it is less than 1, but a problem arises if the person chooses to enter '0.5%'...

Any ideas? Cognos 8.4 here.
Title: Re: Handling '%' if entered in a (numeric) Text Box Prompt
Post by: cogswell on 26 Feb 2011 04:27:07 PM
Anyone?
Title: Re: Handling '%' if entered in a (numeric) Text Box Prompt
Post by: CognosPaul on 27 Feb 2011 12:39:53 AM
The problem here seems to be of a telepathic nature. The users must be trained in the correct way of using the system. It is not the developers job to build a system capable of mind reading or second guessing the user.

It may be difficult at first, but the choice has to be made: Either 0.5 = 50% or 0.5 = 0.5%. Having a system that will attempt to automatically convert the number will result in confusion and incorrect values being entered.
Title: Re: Handling '%' if entered in a (numeric) Text Box Prompt
Post by: Sunchaser on 28 Feb 2011 03:59:03 AM
Hi,

I would tend to agree with PaulM, and in the same time say that this approach - theoretically good - is not enough and cannot be applied "as is".
Yes, users have to be trained, informed, "educated", and if we can say coached.
But, you can rely on the fact that few lines of code correctly set up and tested will always have the same effect / behaviour, you can't rely on the fact that a human being correctly trained will always apply the good things; it is in the human being, a kind of fickle nature (I tried to find a correct translation for "versatile" from french).
With my very small experience, I can say that you should think of building a kind of "idiot proof" system ;-)
From my side, I check on database side if the data sent are correct before doing anything, and I check too on our custom prompt page what is entered.
Title: Re: Handling '%' if entered in a (numeric) Text Box Prompt
Post by: melee on 28 Feb 2011 11:08:42 AM
Ooh. I like these things. I'm going to be a renegade and offer another approach.

Consider the concept of an omnibox, something similar to Google's front page. From that text input, you can do a myriad of things - search, calculations, conversions, everything - you can take that same concept and apply it here.

Using a text input box, you can evaluate your user's input, validate, and process their request. And that's where it starts, simply.

Using Javascript, I'd approach this by attaching an event listener to a text input prompt. Every time that box changes, you should capture the data and run some logic against it; did the user type a % sign? If so, evaluate their input as .05. If not, evaluate it as-is. Did they put a text character in there? They probably didn't mean to, so you can remove it.

You could even hook this logic into the 'Finish' button on the page to change the input box data so it passes to your database correctly. There's a lot of very simple approaches here that will help your users out more.