Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Validation of Input(Report) Parameter
Pranna
Hello Everybody,
I need help on how to validate the input parameters.
I have Date parameters in the input screen and i want to do the validation before i use anywhere in my appln.
Can you please provide me information reg. this.
Thanks in advance
Find more posts tagged with
Comments
mwilliams
Hi Pranna,
If you click on the report parameter in the data explorer window and then click on the script tab under the design window, there's a "validate" script section for the parameter.
Hope this helps.
Pranna
Hi Williams,
Thank you.
Can you please provide me any sample validation.
I can write the logic for the validation but the thing is I don't know how to write there in validation event.
plz help me out.
Thanks in advance.
mwilliams
Pranna,
What are you wanting to validate about the date parameter? What are you checking for? The main thing you need to remember is that whatever check you do, if you return true, the report will run, if you return false, it won't.
Pranna
Hi,
Is the following correct or what....can u plz tell me.
if(params["Date"].value != null){
var str = params["Date"].value
if(str.indexOf("/")>0){
true;
}
else{
false;
}
}
Thanks in advance..
mwilliams
Pranna,
Without testing the script myself, it looks like that should work. You'll probably have to complete the outside if/else statement with another else{false;} just in case the parameter is null. Though if the parameter is set to "required", it may never reach this point as a null value anyways.
Pranna
Williams,
As you said that I have written in script but still I am getting the error...
org.eclipse.birt.report.service.api.ReportServiceException: There are errors evaluating script "if(params["Date"].value != null){ var str = params["Date"].value if(str.indexOf("/")>0){ true; } else{ false; } } else{ false; }": TypeError: Cannot find function indexOf. (#4).
Can you please help me out...
Thanks.
mwilliams
Pranna,
What are you trying to check the date parameter for exactly? This way I can do some quick testing.
Pranna
Hi williams,
I want to check the two things for Date,
1) it is in specified format or not.
For example, MM/dd/yyyy is my format using
2) have to check all the values,
for ex in month, if user enters 15, i mean more than number 12 then i should show the popup etc...
Thanks all...
mwilliams
Pranna,<br />
<br />
I used the following script to check the month:<br />
<br />
if (params["Date"].getMonth() >= 12){<br />
false;<br />
}<br />
else{<br />
true;<br />
}<br />
<br />
However, it did not work because BIRT automatically takes dates such as "16/01/2003" and makes it "04/01/2004". Therefore, when you go to check if the month entered was wrong, BIRT has assumed you meant the date in the future. I don't think there is any way to check this without creating your own custom parameter page and checking the date before sending it to BIRT. Please log a bug for this at <a class='bbc_url' href='
http://www.eclipse.org/birt/phoenix/reportabug.php'>BIRT
: Reporting Bugs and Requesting Enhancements</a>.
analluri
<p>Hi, I have the same requirement to validate input fields.</p><p>I have to validate 2 date fields and 4 List boxes (cascading parameters).</p><p> </p><p>When I click on each of the parameter and wrote below code in validate of script tab, it did not work</p><p> </p><p>if(params["Start Date"].value == null){
false;
}
else {
true;
}</p><p> </p><p>When I see preview in eclipse, validation is working. But, when the report is deployed and accessed through web, it is not working.</p><p> </p><p>Please suggest.</p>
mwilliams
<p>It works for me in BIRT 4.3, deployed to Tomcat 6.0.36. Can you attach a report design in which it doesn't work for you that I can test? Thanks.</p>
analluri
<p>Hi,</p><p> </p><p>Thanks for the response. I am on RTC Version 4.0.1 and BIRT 2.5.</p><p> </p><p>My design is based on custom work items and custom attributes. So, it will not work for you.</p><p> </p><p>Can you explain, when this parameter validate script will be called???</p><p> </p><p>What I am suspecting is, since all the fields are mandatory and if they are not filled, then it will not even go to the report's validate script. In that case, validate will not work.</p><p> </p><p>Let me know if I can try anything to get this error message thrown.</p>
mwilliams
<p>If all the parameters are required and one is not filled, another error is thrown and the report doesn't run, so no, the validate script would not have been executed yet. However, neither will the report. What issue are you having with this? Are you needing to validate your parameters prior to running the report?</p>
analluri
<p>Yes. There is no error message thrown if one of the parameters are not filled. I have to check if all the values are filled or not before executing the report.</p><p> </p><p>Can that be done?</p>
mwilliams
<p>You could probably create your own parameter page using the tag library or modify the current parameter page jsp to show a message that required parameters are not filled out until they all have values.</p><p> </p><p>You can take a look at this blog for help on getting started with a custom parameter page:</p><p> </p><p><a data-ipb='nomediaparse' href='
http://www.birt-exchange.org/forum/index.php?/blog/45/entry-453-custom-parameter-pages/'>http://www.birt-exchange.org/forum/index.php?/blog/45/entry-453-custom-parameter-pages/</a></p>
;
analluri
<p>Hi,</p><p> </p><p>Can this be done in BIRT 2.5 ?</p><p> </p><p>Having own parameter page is very good idea. Could you please share me some links on how to associate jsp to BIRT?</p>
mwilliams
<p>Yes, it can be done with 2.5. The blog should show how you associate the jsp with BIRT. It uses the tag library associated with the viewer as shown in the sample jsp page code. Let me know if you have issues.</p>
analluri
<p>I have to deploy BIRT report in RTC. Can we have customized paramater page for RTC Report??</p>
mwilliams
<p>If you're using the viewer, I don't see why it wouldn't work for you.</p>
analluri
<p>When I downloaded the zip file attached in the blog, I found two files. 1 jsp and 1 rptdesign file.</p><p> </p><p>As per my understanding of the blog, first rptdesign file is created then parameter.jsp is created. In the jsp file, the birt report file is mentioned. So, that links jsp to rptdesign. But how do I deploy this jsp+rptdesign in RTC?</p><p> </p><p>As you know already, in RTC, we can only choose rptdesign file to create a report resource.</p><p> </p><p>Could you please guide me on how I can associate jsp with RTC or deploy jsp in RTC?</p>
mwilliams
<p>Very sorry. I was reading your acronym as RCP, not RTC. I've not used IBM RTC, so I'm not familiar with what you can and cannot do with it. You might have to deploy BIRT separately from RTC to be able to use a custom parameter page. You might ask this question over in the Rational forum to see if anyone over there knows.</p><p> </p><p><a data-ipb='nomediaparse' href='
http://www.birt-exchange.org/forum/index.php?/forum/17-using-birt-with-ibm-rational-tools/'>http://www.birt-exchange.org/forum/index.php?/forum/17-using-birt-with-ibm-rational-tools/</a></p>
;