COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: gp4570 on 04 Jun 2010 02:34:06 PM

Title: Email Hyperlink
Post by: gp4570 on 04 Jun 2010 02:34:06 PM
I have a report that I have created using Report Studio.  The Report list contact info of those who work for the company.  One of the fields I have pulled into the report is the email address for each person.

What I would like to do is to make the email address a hyperlink.  When the user clicks on the email address I want MS Outlook windo to open with the email address in the To: line ready start typing a email.

Any ideas on how I can make this happen?

Thanks -- Todd
Title: Re: Email Hyperlink
Post by: CognosPaul on 07 Jun 2010 03:08:19 AM
If the report is opening in HTML you can drag an HTML item before field in the list (unlock the report first), set it to report expression, and paste:

'<a href="mailto:' + [email] + '?subject=Cognos Rocks&body=This is the default body of the email, you can delete this if you want.">'

And another HTML item (text) after the field with
</a>
Title: Re: Email Hyperlink
Post by: gp4570 on 07 Jun 2010 03:51:28 PM
I added the two HTML items one before the field:

The first HTML item I set the source type to report expression and put exactly this in the report expressioin '<a href="mailto:' + [email] + '?subject=Cognos Rocks&body=This is the default body of the email, you can delete this if you want.">'

The second HTML item I set the source type to report expression and put exactly this in the report expression [/url]


This is the error I got  An error ocurred at or near the position '21'. The variable named '[email]' is invalid.

Title: Re: Email Hyperlink
Post by: CognosPaul on 07 Jun 2010 05:08:29 PM
The reason you're getting the "variable invalid" error is because you're not including the field [email] in the list.

When you reference fields in report expression they have to match exactly what you have in the query. So if the data item is, for example, Employee Email, you need to reference [Employee Email] in the expression. Also, if you're not including that field as an object inside the list, for example if you want to include the email only as a hyperlink on the name field, you need to include it in the list properties. The properties field (inside the properties on the bottom left) forces Cognos to include specific data items in the SQL.

Finally, remember your HTML, that [/url] may not be correct to close the anchor tag.

It wasn't a mistake! The forum software automatically changed < / a > to </a>!
Title: Re: Email Hyperlink
Post by: gp4570 on 10 Jun 2010 10:19:10 AM
Well I am still trying to get this to work.  I have two HTLM items one on either side of my data item named Email Address which is coming from a query named Report Query.

HTML Item #1
<A HREF="mailto:[Report Query].[Email Address]">


HTML Item #2
< /A>

When I try to validate HTML Item #1 I get:
RSV-VAL-0002 Invalid expression<A HREF="mailto:[Report Query].[Email Address]">.CRX-YXX-4010 A parsing error was found at or near the position 0 in the expression "<A HREF="mailto:[Report Query].[Email Address]">".


When I try to validate HTML Item #2 I get:
RSV-VAL-0002 Invalid expression </A>. CRX-YXX-4010 A parsing error was found at or near the position 0 in the expression "</A>.".

Thanks for your help thus far as I have learned some things that I did not know before!
Title: Re: Email Hyperlink
Post by: CognosPaul on 10 Jun 2010 10:31:24 AM
Almost there.

The thing to remember is that report expressions need to be treated as query items. It's trying to interpret <A href... as a function instead of pure text. Instead you need to put single quotes to notify Cognos that it's a string. Concatenate the email address with a +.

It should look like '<a href="mailto:' + [Email] + '">' (that's a single quote followed by a double quote there)


The last HTML item should be set to text or have the < /a> in single quotes.
Title: Re: Email Hyperlink
Post by: gp4570 on 10 Jun 2010 11:03:36 AM
No errors with the syntax now  ;)

HTML Item #1 now looks like:
'<A HREF="mailto:' + [Report Query].[Email Address] +'">'

HTML Item #2 now looks like:
'< /A>'

I can run the report and it works in PDF but not HTML?  In PDF I can click on email address of the person and Outlook window pops up the the email address of ther person selected in the To:

When I run the report -HTML the email address field is not functioning like a hyperlink?  Running in PDF I get a little "hand" icon when I mouse over the email address which is as it should be.  Can I change the color of the email address so it stands out when the report is run from the the ohter data item fields?
Title: Re: Email Hyperlink
Post by: gp4570 on 10 Jun 2010 11:27:05 AM
I got the font color for the email address data item changed to a different color but still don't have running the report in HTML working for the email address mailto feature??
Title: Re: Email Hyperlink
Post by: tupac_rd on 10 Jun 2010 01:06:19 PM
does this help
http://www-01.ibm.com/support/docview.wss?rs=3442&context=SS9RTN&q1=%2bemail&uid=swg21342448&loc=en_US&cs=utf-8&cc=us&lang=all
Title: Re: Email Hyperlink
Post by: gp4570 on 10 Jun 2010 01:46:05 PM
Thanks for the link it will come in handy :)
Title: Re: Email Hyperlink
Post by: gp4570 on 10 Jun 2010 02:02:32 PM
Report now runs via HTML and PDF  ;D

We had some Java script on our default report template which was causing the HTML output to not work properly.  I took the Java script out of the reprot and it runs fine now.

Thanks for the help !
Title: Re: Email Hyperlink
Post by: Robert Kostecki on 23 Oct 2013 04:02:10 AM
Please note for the e-mail hyper-link to work in Cognos 10.1 Excel 2007 output you need Fix Pack 2 (http://www-01.ibm.com/support/docview.wss?uid=swg1PM54866)
Title: Re: Email Hyperlink
Post by: kc9400 on 26 Feb 2016 03:54:55 AM
I know this is an old post but it covers what I'm working with.

I do have an additional question,

'<a href="mailto:' + [signEmail] + '?subject= DATA &body= DATA ">'


In this, how would I get the subject to use a data item value and the body to contain data item values aswell?
Title: Re: Email Hyperlink
Post by: bdbits on 29 Feb 2016 10:08:09 AM
It's just a string expression, so something like:

'<a href="mailto:' + [signEmail] + '?subject= ' + [youritem] + '&body= ' + [youritem1] + ' ' + [youritem2] + '">'
Title: Re: Email Hyperlink
Post by: roddawg on 02 Mar 2016 12:20:39 PM
I used a calculated field [mailto] in my query. Then build a simple string 'mailto:'+[userid]+'@domain.com?Subject=Duplicate Sales Entry&body=Please see me regarding Sales entry for ID:'+left([Customer Sales ID],7)+' '+[Name Last-First-Middle]+ ' on '+left(cast([Sales Date] as varchar(20)),10)
notice the single quotes.  Then insert a hyperlink object make the URL source =[mailto] text source = 'Click to email user'
Title: Re: Email Hyperlink
Post by: neha_cognos on 22 Feb 2019 02:09:51 AM
can i also attach report output itself with this method or attach/paste a screenshot of a visualization ( eg- crosstab in my case)