COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: hittony on 21 Nov 2013 03:20:43 AM

Title: Hyperlink
Post by: hittony on 21 Nov 2013 03:20:43 AM
Hello,

I try to creat a safe hyperlink without using the toolbox, because i need some data items and some parameters to form the URL. A form tag with the post method in an HTML item seems to be a solution, but i don't know how to get the right code.

Here is an unsuccessful try :
<form name="frm" action="http://www.cognoise.com/" method="post" target="_blank"></form>
<a href="javascript:frm.submit();">Cognoise</a>

Title: Re: Hyperlink
Post by: CognosPaul on 21 Nov 2013 03:58:42 AM
Cognos outports HTML reports inside a form. You cannot nest forms, so you'll need to find a work-around.

Can you be more specific as to what you're trying to accomplish?
Title: Re: Hyperlink
Post by: hittony on 21 Nov 2013 07:22:24 AM
Quote from: CognosPaul on 21 Nov 2013 03:58:42 AM
Cognos outports HTML reports inside a form. You cannot nest forms, so you'll need to find a work-around.

Can you be more specific as to what you're trying to accomplish?

Thank you for your quick reply Paul. I just want a hyperlink in a Cognos report without showing any URL query string in the adresse bar. Firstly, this is a secuirty issue, secondly, the URL can be too long to be accepted by a web browser.
Title: Re: Hyperlink
Post by: CognosPaul on 21 Nov 2013 08:13:07 AM
Try the cognosLaunchInWindow (http://cognospaul.com/2012/05/09/rendering-reports-in-iframes/) function. That will pass the parameters via POST. The article I linked to describes using it to open an iframe. Simply use _blank as the target and it will open a new window.

The article was written before 10.2, so it's not using the Prompt API. There are also easier and cleaner ways of getting the prompt values into the function than what's written, but this should point you in the right direction.
Title: Re: Hyperlink
Post by: hittony on 21 Nov 2013 11:25:07 AM
Quote from: CognosPaul on 21 Nov 2013 08:13:07 AM
Try the cognosLaunchInWindow (http://cognospaul.com/2012/05/09/rendering-reports-in-iframes/) function. That will pass the parameters via POST. The article I linked to describes using it to open an iframe. Simply use _blank as the target and it will open a new window.

The article was written before 10.2, so it's not using the Prompt API. There are also easier and cleaner ways of getting the prompt values into the function than what's written, but this should point you in the right direction.

'<script>
function launchURL()
{
cognosLaunchInWindow("_blank", "", "ui.gateway", "' +
[SERVEUR] +
'/file_a.aspx", "ui.tool", "CognosViewer")
}
</script>
<a href="JavaScript:launchURL();">Hyperlink</a>'


It works.

'<script>
function launchURL()
{
cognosLaunchInWindow("_blank", "", "ui.gateway", "' +
[SERVEUR] +
'/file_b.aspx", "ui.tool", "CognosViewer", "string", "' +
[VALUE] +
'")
}
</script>
<a href="JavaScript:launchURL();">Hyperlink</a>'


It doesn't work with a query string, what is wrong in the second code above ? :o
Title: Re: Hyperlink
Post by: CognosPaul on 21 Nov 2013 02:36:14 PM
In what way isn't it working? What kind of error are you getting?

Two possibilities.

1. If string is the parameter, it should be p_string.
2. If value is a numeric, cast it into a string.
Title: Re: Hyperlink
Post by: hittony on 22 Nov 2013 04:08:36 AM
Quote from: CognosPaul on 21 Nov 2013 02:36:14 PM
In what way isn't it working? What kind of error are you getting?

Two possibilities.

1. If string is the parameter, it should be p_string.
2. If value is a numeric, cast it into a string.

"string" is a parameter and it isn't a numeric, but "p_string" doesn't work either.
There is no errer message, but the page i should get is [SERVEUR]/file_c.aspx which is the result of [SERVEUR]/file_b.aspx?string=[VALUE], instead of [SERVEUR]/file_b.aspx which remains in the browser's adresse bar.

I think that the "string" isn't send correctely.
Title: Re: Hyperlink
Post by: CognosPaul on 27 Nov 2013 12:27:38 AM
I think I understand now.

My mistake, the cognosLaunch function won't help as that is designed to open a cognos report in a new window.

To send via post you will need your own form element which you can't normally do inside a Cognos report. 

Take a look here:
http://stackoverflow.com/questions/3951768/window-open-and-pass-parameters-by-post-method-problem

That shows a few possible ways of generating a new form to do what you need.