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)
Default Parameter using Javascript created using expression builder
JagThripp
<p>Hello Everyone,</p>
<p> </p>
<p>Newbie here trying to create an Eclipse report that prompts for values from user at run time, there are two *required* parameters and one *optional* parameter. For the required parameters I have tried to set a default value at run time, my problem is that I am not able to get the values to show in the parameter field when I try to preview the report.</p>
<p> </p>
<p>The parameter I have is *BirtDateTime.year(BirtDateTime.Now()) + BirtDateTime.month(BirtDateTime.Now())*</p>
<p>This is creating a value that is a combination of year and month (Financial Period) YYMM so the user can run the report for the current period or adjust them accordingly.</p>
<p> </p>
<p>As far as I am aware (assumption) the expression is valid as there is no error when I use the validation option in the expression builder.</p>
<p> </p>
<p>The two parameters I have created are called FinStart and FinEnd both use their own version of the expression pasted above as the default value. Due to this missing information the values are not being populated at run time causing the report to fail.</p>
<p> </p>
<p>var where = params["where"];<br>
if (params["FinStart"].value)<br>
where = " R.FINANCIALPERIOD BETWEEN " + params["FinStart"].value;<br>
if (params["FinEnd"].value)<br>
where = where + " AND " + params["FinEnd"].value;<br>
if (params["vendor"].value)<br>
where = where + where + " AND " + params["vendor"].value;</p>
<p> </p>
<p>This is the (clumsy) attempt at getting values into the parameters then into the query.</p>
<p> </p>
<p>Thanks.</p>
Find more posts tagged with
Comments
jfranken
<p>For the default values, the functions you called return integers. Your code is adding them together, not concatenating. Unless there is a specific reason why you can't include the day, I recommend using the following expression for the default:</p>
<p> </p>
<p>BirtDateTime.firstDayOfMonth(BirtDateTime.today())</p>
<p> </p>
<p>This way you are using a date rather than converting to a string. If you want to convert to a string, then I believe the code is:</p>
<p>Formatter.format(BirtDateTime.today(), "YYMM")</p>
<p>(I haven't had a chance to test this.)</p>
<p> </p>
<p>Your code to manipulate the query is incorrect, but you shouldn't need that code. The start and end date values are required. All you need to do is replace the vendor value with a wildcard if the value is not a valid value. There is no need to manipulate the structure of the query.</p>
JagThripp
<p>Hello Jeff,</p>
<p> </p>
<p>Thanks for the insight on this. We have a field that is type Varchar(6) that has the FINANCIALPERIOD stored in it.<br><br>
I was trying to display the latest FP to the user in the parameter entery dialog box. (as you no doubt already guessed)</p>
<p> </p>
<p>So that I am on the same page as you.</p>
<p>Were I have *BirtDateTime.year(BirtDateTime.Now()) + BirtDateTime.month(BirtDateTime.Now())* entered,</p>
<p>I simply replace the old javascript with your Formatter.format(BirtDateTime.today(), "YYMM") script?</p>
<p> </p>
<p>And thanks again for your assistance.</p>
<p> </p>
<p>Jag</p>
jfranken
<p>Hi Jag,</p>
<p> </p>
<p>I tested the expression:</p>
<p> </p>
<p>Formatter.format(BirtDateTime.today(), "YYMM")</p>
<p> </p>
<p>It displays the two digit year concatenated with the two digit month in the parameter box. Be sure the JavaScript expression type is selected (see attached screenshot s1.png).</p>
<p> </p>
<p>Regards,</p>
<p>Jeff</p>
JagThripp
<p>Cool we are on the same page, thanks Jeff.</p>