官术网_书友最值得收藏!

Dynamic links to an external website (a Google Maps example)

In this recipe, we will introduce you to the Hyperlink component.

Let's say that a report shows retailer information by products. It shows various fields like Retailer name, Contact information, City, and Postal zone. Business wants to have a link to Google Maps that will show a retailer's place on the map using the Postal zone information.

As the addresses might change in the backend, the technique needs to be dynamic to pick up the latest postal zone.

Getting ready

Create a simple list report that shows retailer information by Product lines as shown in the following screenshot:

How to do it...

In this recipe, we will add a hyperlink to the report that will open a Google map once you have clicked on it. To do this, perform the following steps:

  1. From the Toolbox, drag a hyperlink object onto the report as a new column as shown in the following screenshot:
  2. Change its Text property to Map. Set the URL Source Type to Report Expression and define the report expression as http://maps.google.com/maps?q=' + [Query1].[City (multiscript)] as shown in the following screenshot:
  3. Run the report to test it as shown in the following screenshot:

As you can see, there is a link for each retailer record. If you press Shift and click on the link, it will open Google Maps for the corresponding postal zone in a new window.

How it works...

Here we are using the Hyperlink component of Cognos Report Studio. We can define the URL as any static link.

However, for our requirements, we have defined a report expression. This allows us to provide a dynamic link which picks up the latest postal zone from the database. We are passing the postal zone to Google Maps as part of a URL.

The Hyperlink component works in HTML as well as Excel and PDF report formats. This object currently does not have the property to define whether the link target should open in a new window or the same window. Just clicking on the link opens the target in the same window, whereas pressing Shift and then clicking on the link opens the target in a new window.

There's more...

You can use this technique to call any external website that accepts parameters within a URL. You can pass multiple parameters too.

主站蜘蛛池模板: 卢龙县| 延安市| 镇康县| 阳谷县| 延安市| 怀仁县| 武汉市| 噶尔县| 桓台县| 永州市| 尉犁县| 塔河县| 南丰县| 台山市| 嘉黎县| 青海省| 湖州市| 青州市| 双柏县| 沙湾县| 扎兰屯市| 都昌县| 鸡东县| 兴安盟| 苗栗县| 图片| 香港 | 玉门市| 大邑县| 中方县| 巴彦淖尔市| 抚宁县| 筠连县| 江都市| 西贡区| 宜章县| 盐边县| 扎兰屯市| 陇川县| 固安县| 彭泽县|