COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: vemula on 14 Feb 2017 12:30:24 PM

Title: Passing parameter values from one report to another through Java script ?
Post by: vemula on 14 Feb 2017 12:30:24 PM
Hello Everyone,

I am new to cognos and java script as well, i got requirement like below

i have two reports
report 1 and report 2

when i click on report 1 heading it popups a window ( it does not re-direct ) and shows report 2 ( wrote java script for this )

Here i am applying multi select filter on report1, the data should filter on report 2 also

when i select one value in filter it is applying on both reports

when it is multi selected then report 2 is filtering with only one value( any value from selection )

my script is like below

<script>
jq(document).on("click","span[lid^='New Business Direct Premiums Written']",function(){
var parentEl = jq(this).closest("table[lid^='DITABLEHOVER']");
var popupWidth = parentEl.width() * 2;
var popupHeight = parentEl.height()-10;
var popupOffset = getPopupOffset(parentEl);
if(jq(".report_popup_iframe").length > 0){
   jq(".report_popup_iframe").remove();
}
var reportPath = "report 2";
var reportParams = getParameterVals();
var reportURL = getReportURL(reportPath,reportParams);
var reportIframe = '<div class="report_popup_iframe" style="position: absolute; margin-left: 0px; '+popupOffset+' margin-top: 0px; width: '+popupWidth+'px; height: '+popupHeight+'px;">';
reportIframe += '<div class="report_iframe_close" style="position: absolute; top:6px; right:8px; font-size: 12px; cursor: pointer; padding: 5px;">X</div>';
reportIframe += '<iframe src="'+reportURL+'" style="width: 100%; height: 100%; border: none;"></iframe></div>';
jq(this).closest("table[lid^='DITABLEHOVER']").parent().prepend(reportIframe);
});
</script>


your help is highly appreciated

Thanks in advance

Regards
Vemula



Title: Re: Passing parameter values from one report to another through Java script ?
Post by: AnalyticsWithJay on 14 Feb 2017 12:37:05 PM
Hello,

There's a much easier way to implement this.

1. Create a Drill-Through link on Report 1 heading.
2. Set the Report property to Report 2.
3. Check the 'Open in new window' property.
4. Edit the parameters to specify which parameters you want to pass.

Ideally, you want to avoid javascript whenever possible as it could break your application during upgrades.
Title: Re: Passing parameter values from one report to another through Java script ?
Post by: vemula on 14 Feb 2017 12:46:58 PM
Thanks Jay for reply

But user does not want that way, on the same window it opens a block with report 2 with close button on the top right

Regards
Vemula
Title: Re: Passing parameter values from one report to another through Java script ?
Post by: AnalyticsWithJay on 14 Feb 2017 01:34:19 PM
Could you alert(reportURL) and paste the contents here? Could you highlight the parameter you're trying to send multiple values of, and what the values you selected are?

On report 2, make sure your filter uses IN() instead of the equal sign (=). If you use '=', Cognos will assume you're looking for a single value.
Title: Re: Passing parameter values from one report to another through Java script ?
Post by: CognosPaul on 14 Feb 2017 04:03:12 PM
Do you want it to pop up in a new window, or do you want it to appear in an iframe?

1. new window, read: http://cognospaul.com/2014/03/20/passing-parameters-without-refreshing-page/
2. iframe, read: http://cognospaul.com/2012/05/09/rendering-reports-in-iframes/
Title: Re: Passing parameter values from one report to another through Java script ?
Post by: dougp on 14 Feb 2017 04:29:34 PM
I agree with CognoidJay.  You should use a drill-through.

I don't understand what you are saying about the popup.  Is the requirement for the target report to appear in a new window (or tab) or in the same window?  Either way, this can be controlled in the drill-through definition.

Report 2 filtering only on the first value of a multi-select may be from an error in report 2.  Is the filter using = or in for the operator?