Reputation: 59
i had working with more optional parameter like country,state,city and i have wrote some script in before open but its not working ...
before open::
if (params["productline"].value && params["country"].value)
{
q1=this.queryText = this.queryText + " AND PRODUCTLINE = '" + params["productline"].value +"'"+" and COUNTRY = '" + params["country"].value + "'"+"group by country";
reportContext.getDesignHandle().findParameter("state").dropAndClear();
reportContext.getDesignHandle().findParameter("city").dropAndClear();
Packages.java.lang.System.out.println ("Query1:" +q1);
}
else if (params["productline"].value && params["state"].value)
{
q2=this.queryText = this.queryText + " AND productline = '" + params["productline"].value +"'"+" and state = '" + params["state"].value + "'"+ " group by state";
reportContext.getDesignHandle().findParameter("country").dropAndClear();
reportContext.getDesignHandle().findParameter("city").dropAndClear();
Packages.java.lang.System.out.println ("Query3:" +q2);
}
else
{
q3=this.queryText = this.queryText + " AND productline = '" + params["productline"].value +"'"+" and city = '" + params["city"].value + "'"+ " group by city";
Packages.java.lang.System.out.println ("Query3:" +q3);
reportContext.getDesignHandle().findParameter("state").dropAndClear();
reportContext.getDesignHandle().findParameter("city").dropAndClear();
}
Upvotes: 0
Views: 1519
Reputation: 1069
if you are having the screenshots provided by the below link1 link2 then
you have to do a simple logic in your javascript like this
var rptFlag = ""
if counrty is selected then assign rptFlag = 'country'
if state is selected then assign rptFlag = 'state'
if city is selected then assign rptFlag = 'city'
pass this as a rptFlag parameter to the report and
in before open
you have to check like this...
if (params["rptFlag"].value=='country')
{
/* your query */
}
else if (params["rptFlag"].value=='state')
{
/* your query */
}
else
{
/* your query */
}
Upvotes: 1