Report parameter validation message with Birt - validation

I'm creating a BIRT report using certain parameters. I have an int parameter (Number of months) which values can be from 1 to 12.
I need to check if the value is bigger than 12. In such case it should show me a customized message and not an error like it is doing right now.
Error:
org.eclipse.birt.report.service.api.ReportServiceException: The validation for parameter "nummonths" fails.
Current script:
if (params["nummonths"].value > 12 )
{
false;
}
else
{
true;
}
I create reports in BIRT to upload it to IBM Maximo Asset Management system. Maybe there is a different way to solve this in Maximo.
Thanks for your time! Hopefully will help others.

You could create a dynamic text styled as a warning, and hide it (property "visibility") with an expression such
params["nummonths"].value <= 12
There is an example of a such approach here, if we select more than 10 countries or more than 10 indicators, a warning label is displayed at the top of the report.
An interesting point is, although a warning is displayed we can additionally create a rule to replace the wrong parameter value in a script such onCreate. This way the report can correctly run. For example in your case, we could do in a script:
if (params["nummonths"].value > 12){
params["nummonths"].value=12;
}
Alternatively, you could also drop some report elements in "beforeFactory" when the parameter is wrong.

Related

VS Reporting Services - [rsInvalidFormatString] The Format value for the textrun is not valid

I wrote code in SQL Server that gives the year, the month and some data for those months in separate columns. The column for month (MM) gives months in numeric digits (1 to 12).
The code I used was:
Select ....
,Month(IRDate) AS MM
,...
I created a report in MS VS Report builder and included all the data in table columns. The report runs fine. However, at the bottom I get the below warning message:
[rsInvalidFormatString] The Format value for the textrun
‘MM.Paragraphs[0].TextRuns[0]’ is not valid. Format specifier was
invalid.
I checked the formatting for that cell, it is set to default - No formatting.
In the report, I've set the parameter to have a default value as
=DateValue("September 01, 2016")
Would that be the issue? Maybe the default value is not the right format? I removed the default value and kept it as no specified value. Warning message still comes up.
How can I fix this?
Have you tried formatting the textbox properties that holds the MM value to be a number datatype with no decimal places?
Regarding your other question about the default parameter value, I have typically seen DateValue formatted as such: 9/1/2016
Also, is your parameter datatype set to Date/Time?
Apparently, the error message '[rsInvalidFormatString] The Format value for the textrun....' is a log message. Rectifying the problem does not take away the message because it is a log message. So even after you correct the issue, the message will still show.
The only way to remove that message is to simply restart Visual Studio. When Visual Studio starts back up, the log is cleared and you won't see the message any more.
"Who knew healthcare would be so complicated?" ;)

BIRT Repeating only part of a header

What I am currently trying to do in BIRT 4.5 is repeat only a specific part of my tables header. However when I set it to repeat the header it always repeats the entire header.
Is there a way to only repeat a specific part of the header?
In my example - there is two headers, the "table name" and the "column headings". I only want the column headings to repeat. I have a feeling its likely going to be a scripted fix, but have no idea where to go to start it.
this might get tricky because headers can be repeated for groups but also for pagebreaks.
Not the most fancy, but you should get something working by defining a global variable on the page script
var headerCount = 0;
Then select an element in the header, open the onPrepare script and have it increment the counter:
headerCount = headerCount + 1;
with this information, you can make true/false statements in the visibility property.
Each object has onPrepare, onCreate, onRender and onPagebreak scripts. Not sure what the exact difference, so you have to experiment a bit with this. (because when an element should increase the counter, but is not rendered due to the visibility clause, you can get unexpected results.)
Good luck!

How to limit the characters in input field in crystal report

I am using crystal report 2008, i have a report and that has a input field called "Departure_no".
In this input field we can type maximum of four departure_no (Eg: 2345,234,2345,23456), if it exceeds this limit(more than 4 numbers-can count with 3 commas(,)), this input field should not allow to type further.
Is there any way to achieve this by formula or something else by crystal report??
Thanks in advance!!
Priya
try below
use alerts to show the message: I am showing on a database field
Go to Report--> Alert --> Create or modify alert
When a window is opened provide the following:
required name
Required message
Condtion when alert need to be displayed
You can give condition as
if Length(databasefield)> 4 //you need only 4 chars hence this condition
then true
else false
Click ok.
Now you will get message
Let me know of you are looking for something different

Pass Crystal parameter from main report to command object

I find lots of info about passing parameter into subreport, but nothing about passing it from main report into command object in main report. (This is the closest I could find.)
The command object received from the vendor (names changed to reduce length) contains
left join LOC L on L.ID = P.Loc_ID
We add parameter "Area" to the main report. {?Area} does what we expect in formulas, but it won't work in a record selection because it can't be matched to anything coming out of the command object. If I replace table LOC in the cited line as
left join **(select * from LOC where A = {?Area})** L on L.ID = P.Loc_ID
then SQL Server complains of "syntax error, permission violation, or other nonspecific error" [sic]
If I create the parameter in the command object editor (even though it already exists outside), then the whole Crystal IDE crashes!
The command object already has parameters that it magically gets from the main report. Must I remove it from the main report (proctalgia) before adding it to the command object? I can't find anything on any menus to link the two parameters together, like I can for a subreport.
Version 2008, if that matters.
If you are using an SQL command, don't create the parameters in the main report. The window where you put your SQL has a section called Parameter List. Create all your parameters relating to the query there and it will be transfered to the main report.
In your coding you have {?Area}, create a parameter with the name Area.
I found a video demonstrating it. It's an old version of Crystal Reports but still works the same.
http://www.youtube.com/watch?v=BHNHsIUbcn8
I found creating the command object and the parameter FIRST is the key. The parameter (say it is InstNo), is then created in the subreport. You can then use "Change SubReport Links" (right click on the subreport), and select that parameter as the parameter to link to. So basically do it backwards, create the command object first, then link it back to the main report. For whatever reason if you do it the other way it does not work (even if the name is the same). Just my experience.

Crystal Reports - change group header suppress formula programmatically

Using Crystal Reports 10 and vb6/classic (although I expect its the same in any language),
is it possible to change a suppression formula on a Group header section dynamically from code.
I'm basically changing the GroupConditionField on a specific group dynamically according to user input, but on that group header there is a suppression field formula containing a check on a grouped sum.
Sum ({#ColourTotal}, {Table.Field}) =0
If this is true, the group gets suppressed. This obviously comes up with an error complaining it can't find the group when the GroupConditionField is changed through code.
So is there a way to change the suppress formula for a specific group from within code?
I apologize this is C# but I had it handy. I need to so something similar so I have a formula that I set to a value from my program. The report checks this value to decide whether to suppress or not. I suspect you can use the same technique to change the formula, but I'm too lazy to test it my self.
report.DataDefinition.FormulaFields["Florida"].Text = (Convert.ToBoolean(option.EffectiveValue) == true ? "1" : "0");
This code just sets the formula field, "Florida" to either 0 or 1.
I believe I have found a way to do it using the Group Selection Formula under
Report->Selection Formulas-> Group inside the actual report.
Not ideal and will involve some reformatting but should work.

Resources