Home
Analytics
Validate Script on Parameter ; Customize messages
Kenichi
Dear Experts
I am trying to figure out how to populate my own message when the validation script on Parameter is HIT.
On the report, I am using two parameters, transactionDateFrom and transactionDateTo, and let the use to choose the date range. For example, from 06-20-2011 to 06-30-2011.
There is a validation that I set on this transactionDateTo at Validate Script. This validation let users to choose the range of 7 days only. The javascript is as simple as the following.
BirtDateTime.diffDay(params["transactionDateFrom"].value, params["transactionDateTo"].value) <= 7
However, the problem is that I cannot choose the error message generated from this validation. It always says "Report generation failed. Cause: The validation for parameter "transactionDateTo" fails."
Could anyone teach me how to populate my own message, like "Please limit the date range for 7 days."
Thanks and Best Regards,
Ken
Find more posts tagged with
Comments
johnw
Without modifying the web viewer, you cannot change the error message. Your script is incorrect, the Validate event can only return a true or a false. If you need to customize the error message, consider using an external parameter page and passing the results into the web viewer. This will give you more control, and you can use Date/Time pickers to select your date range.
The following is an example parameter validation script:
if (params["NewParameter"].value == "1")
{
(true);
}
else
{
Packages.java.lang.System.out.println("Error, value of param is not '1'");
(false);
}
rihanna
Could you please show how to modify the web viewer? Do I need to create a web project containing BIRT report? Where can I deploy the project?
Kenichi
<blockquote class='ipsBlockquote' data-author="'johnw'" data-cid="79353" data-time="1309394212" data-date="29 June 2011 - 05:36 PM"><p>
Without modifying the web viewer, you cannot change the error message. Your script is incorrect, the Validate event can only return a true or a false. If you need to customize the error message, consider using an external parameter page and passing the results into the web viewer. This will give you more control, and you can use Date/Time pickers to select your date range.<br />
<br />
The following is an example parameter validation script:<br />
<br />
if (params["NewParameter"].value == "1")<br />
{<br />
(true);<br />
}<br />
else<br />
{<br />
Packages.java.lang.System.out.println("Error, value of param is not '1'");<br />
<br />
(false);<br />
}<br /></p></blockquote>
<br />
<br />
Mr Johnw.<br />
<br />
As you told me it looked like the populating customized message was not easy task. <br />
Thanks for your support.
sarmistha_birt
<p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"]Hi Kenichi,[/font]</span></p><p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"] [/font]</span></p><p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"]Could you kindly tell me how did you implement the custom message? I have a very similar requirement as that of yours which is as below: [/font]</span></p><p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"] [/font]</span></p><p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"][color=#000000;]I have a report with “Begin Date†and “End Date†as report input parameter. I want to restrict the user to view only 1 month data. I have used the following code in the “validate†script of end_date input parameter.[/color][/font]</span></p><p> </p><p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"]<strong>[color=#000000;]if[/color]</strong>[color=#000000;](DateTimeSpan.months(params["begin_date"],params["end_date"]) == 0){[/color][/font]</span></p><p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"]<strong>[color=#000000;]true[/color]</strong>[color=#000000;];[/color][/font]</span></p><p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"][color=#000000;]}<strong>else</strong>{[/color][/font]</span></p><p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"]<strong>[color=#000000;]false[/color]</strong>[color=#000000;];[/color][/font]</span></p><p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"][color=#000000;]}[/color][/font]</span></p><p> </p><p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"][color=#000000;]This works but it does not tell user that he is allowed to view only 1 month data.[/color][/font]</span></p><p> </p><p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"][color=#000000;]So I want to show a custom error message to the user in the else block. The error message that I want to display is "Max allowed duration for the report is 1 month only".[/color][/font]</span></p><p> </p><p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"][color=#000000;]Could you kindly help me in implementing this?[/color][/font]</span></p><p> </p><p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"][color=#000000;]Thanks & Regards,[/color][/font]</span></p><p><span style="font-size:12px;">[font="tahoma, geneva, sans-serif;"][color=#000000;]Sarmistha[/color][/font]</span></p>
sarmistha_birt
Dear Experts,
Could you kindly let me know if it is feasible to show a custom error message in BIRT report and if feasible then what is the recommended way of doing it?
I need to implement the above mentioned requirement urgently.so need your expert advise.
Thanks.
DanielPublic
<blockquote class="ipsBlockquote"><a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/22732-validate-script-on-parameter-customize-messages/?p=79353'>http://developer.actuate.com/community/forum/index.php?/topic/22732-validate-script-on-parameter-customize-messages/?p=79353</a>
;
<p> </p>
<p>Packages.java.lang.System.out.println("Error, value of param is not '1'");</p>
</blockquote>
<p>I use this command in the parameter validation script. When running the report, I do not have an error message yet the condition to have the error meesage is met.</p>
<p> </p>
<p>What instruction do i miss and where do i register it so that it works?</p>
<p> </p>
<p>N.B. : The version of Birt that I use is the version 2.5.1</p>
<p> </p>
<p>Thank you in advance.</p>