Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Optional Report Title parameter
whitey2
This is a newbie question - so apologies but here goes. I am trying to create a parameter to substitute into a report title. The report title is a dynamic text field defined on the master page and in the expression builder I have simply defined it to use the report title parameter value. I want to have the ability to have the parameter as optionally entered and if there is no value entered then the report title should default to a default value. The parameter has been defined as a text box, I have unchecked the "is required" value and have put in a default value. When I run the preview report the parameter prompts with text box to enter a value and radio button to check either null value or check and enter text. If I check null value I do not get my default report title and If I do not enter anything in the text box I also do not get my default value. How do I make this an optional parameter with a default value.
Thanks in advance for your assistance
Find more posts tagged with
Comments
mwilliams
In your dynamic text field, you can simply create an expression that gives a default title if the value of the parameter is null. Hope this helps.
whitey2
Yes it helped - thanks
mwilliams
Not a problem. Let us know whenever you have questions!
Nikola18
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="81917" data-time="1314288358" data-date="25 August 2011 - 09:05 AM"><p>
In your dynamic text field, you can simply create an expression that gives a default title if the value of the parameter is null. Hope this helps.<br /></p></blockquote>
<br />
I have the same question, but I have around 40 parameters.<br />
And I would not like to write code for each of them.<br />
How can I make a cycle something like this:<br />
<br />
<em class='bbc'>for (i=1;i<=params.count;i++) {<br />
<p class='bbc_indent' style='margin-left: 40px;'>if(params
.value != null) {<br />
<p class='bbc_indent' style='margin-left: 40px;'>Title = Title + params
.Name + " = " + params
.value;</p>}</p>}<br />
</em>
mwilliams
So, you have 40 parameters that you want to list out like that if they're not null?
Nikola18
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="95015" data-time="1328423554" data-date="04 February 2012 - 11:32 PM"><p>
So, you have 40 parameters that you want to list out like that if they're not null?<br /></p></blockquote>
Exactly.<br />
<br />
Or can You advise me documentation, where I can find information out <br />
about all properties & methods of the "params" global variable.<br />
Also about other global objects with their properties & methods?<br />
<br />
I use Actuate BIRT Designer Professional <br />
Version: 11.0.3<br />
Build id: 20111028
mwilliams
Try something like this in your dynamic textbox:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var paramsOutput = "";
var paramArray = reportContext.getDesignHandle().getParameters();
var paramCount = paramArray.getCount();
for( var i = 0; i < paramCount; i++ )
{
var paramName = paramArray.get( i ).getFullName();
var paramVal = reportContext.getParameterValue( paramName );
if (paramVal != null){
paramsOutput = paramsOutput + paramName + " = " + paramVal + "<br/>";
}
}
paramsOutput;
</pre>
<br />
Hope this helps.
Nikola18
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="95023" data-time="1328462363" data-date="05 February 2012 - 10:19 AM"><p>
Try something like this in your dynamic textbox:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var paramsOutput = "";
var paramArray = reportContext.getDesignHandle().getParameters();
var paramCount = paramArray.getCount();
for( var i = 0; i < paramCount; i++ )
{
var paramName = paramArray.get( i ).getFullName();
var paramVal = reportContext.getParameterValue( paramName );
if (paramVal != null){
paramsOutput = paramsOutput + paramName + " = " + paramVal + "<br/>";
}
}
paramsOutput;
</pre>
<br />
Hope this helps.<br /></p></blockquote>
<br />
Thanks. It works. Wonderful!<br />
<br />
And few more quostions: <br />
1. If I have the Static List box parameter, how can I get a display text of them selected values?<br />
2. How can I get parameters flags: "Is Required", "Hidden", "Echo input", "Duplicate values", "Multiple Values" and so on?<br />
3. If parameter
is a Group, how can I get its items parameters?
mwilliams
For 1, there is an issue in Actuate BIRT on getting the displayText. Normally, you'd use this line:
var paramDispText = reportContext.getParameterDisplayText(paramName);
But that doesn't work in Actuate. It only works in OS BIRT.
For 2, you can use lines like:
reportContext.getDesignHandle().getParameters().get(0).getBooleanProperty("isRequired");
reportContext.getDesignHandle().getParameters().get(0).getBooleanProperty("hidden");
etc.
For 3, To step through parameter groups, use:
var paramArray = reportContext.getDesignHandle().getAllParameters();
var paramCount = paramArray.size();
instead of:
var paramArray = reportContext.getDesignHandle().getParameters();
var paramCount = paramArray.getCount();
Nikola18
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="95072" data-time="1328549054" data-date="06 February 2012 - 10:24 AM"><p>
For 1, there is an issue in Actuate BIRT on getting the displayText. Normally, you'd use this line:<br />
<br />
var paramDispText = reportContext.getParameterDisplayText(paramName);<br />
<br />
But that doesn't work in Actuate. It only works in OS BIRT.<br /></p></blockquote>
Maybe, can we find DisplayText over looking for the list of static values for this parameter by value?<br />
<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="95072" data-time="1328549054" data-date="06 February 2012 - 10:24 AM"><p>
For 2, you can use lines like:<br />
<br />
reportContext.getDesignHandle().getParameters().get(0).getBooleanProperty("isRequired");<br />
reportContext.getDesignHandle().getParameters().get(0).getBooleanProperty("hidden");<br />
etc.<br /></p></blockquote>
I guess, are there getProperty, getNumberProperty, getTextProperty also?<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="95072" data-time="1328549054" data-date="06 February 2012 - 10:24 AM"><p>
For 3, To step through parameter groups, use:<br />
<br />
var paramArray = reportContext.getDesignHandle().getAllParameters();<br />
var paramCount = paramArray.size();<br />
<br />
instead of:<br />
<br />
var paramArray = reportContext.getDesignHandle().getParameters();<br />
var paramCount = paramArray.getCount();<br /></p></blockquote>
Ok. And how can I divide groups and parametres?<br />
<br />
<br />
PS: Thanks that waste time on my silly questions.
mwilliams
Not sure what you're wanting to do for dividing groups, but this might help get you started with how you want to lay those out.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
pOutput = "";
pArray = reportContext.getDesignHandle().getParametersAndParameterGroups();
pCount = pArray.size();
for( var i = 0; i < pCount; i++ )
{
var paramArrayElement = pArray.get(i);
if (paramArrayElement.getClass() == "class org.eclipse.birt.report.model.api.ParameterGroupHandle"){
var paramGroupName = paramArrayElement.name;
var groupParameters = paramArrayElement.getParameters();
var groupParamSize = groupParameters.getCount();
for( var j = 0; j < groupParamSize; j++){
var pName = groupParameters.get( j ).getFullName();
var pVal = reportContext.getParameterValue( pName );
if (pVal != null){
pOutput = pOutput + paramGroupName + ": " + pName + " = " + pVal + "<br/>";
}
}
}
else{
var pName = pArray.get( i ).getFullName();
var pVal = reportContext.getParameterValue( pName );
if (pVal != null){
pOutput = pOutput + pName + " = " + pVal + "<br/>";
}
}
}
pOutput;
</pre>
Nikola18
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="95087" data-time="1328560117" data-date="06 February 2012 - 01:28 PM"><p>
Not sure what you're wanting to do for dividing groups, but this might help get you started with how you want to lay those out.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
pOutput = "";
pArray = reportContext.getDesignHandle().getParametersAndParameterGroups();
pCount = pArray.size();
for( var i = 0; i < pCount; i++ )
{
var paramArrayElement = pArray.get(i);
if (paramArrayElement.getClass() == "class org.eclipse.birt.report.model.api.ParameterGroupHandle"){
.......skip.....skip......skip........
}
pOutput;
</pre></p></blockquote>
That was exactly necessary for me!<br />
But what is a different between <em class='bbc'><span class='bbc_underline'>getAllParameters()</span></em> and <em class='bbc'><span class='bbc_underline'>getParametersAndParameterGroups()</span></em>?<br />
The result is the same.
mwilliams
If I replace getParametersAndParameterGroups with getAllParameters, in my example, I get duplicates of my parameters that are in the group. This is because getAllParameters flattens the parameter groups and returns all parameters within the groups. With getParametersAndParameterGroups, only the parameters not in groups and the parameter group handles are returned. Here, you can step through the parameter groups, then, and have access to the group name, which you'll see that the grouped parameters have a group name before them in the list.