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

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.

主站蜘蛛池模板: 彰化市| 舟山市| 兰州市| 台州市| 阳原县| 古田县| 井研县| 浠水县| 丹棱县| 盐津县| 宾阳县| 凤阳县| 临西县| 聂荣县| 荥经县| 绥宁县| SHOW| 长沙县| 通渭县| 屯昌县| 高邮市| 昂仁县| 延吉市| 景谷| 叶城县| 永定县| 留坝县| 呼伦贝尔市| 轮台县| 家居| 凉城县| 凤冈县| 遵化市| 汾阳市| 如皋市| 珲春市| 建昌县| 抚顺市| 德清县| 专栏| 五家渠市|