Dynamic links to external website (Google Map example)

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

A report shows retailers 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 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 Retailers information by Product lines.

Getting ready

How to do it...

  1. From the 'Insertable Objects' toolbox, drag a hyperlink object onto the report as a new column.
    How to do it...
  2. Change its Text property to Map. Set the URL Source Type to Report Expression and define the report expression as follows:
    'http://maps.google.com/maps?q=' + [Query1].[City]
    
    How to do it...
  3. Run the report to test it.
    How to do it...

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

How it works...

Here we are using the 'Hyperlink' component of CRS. 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 formats of report. 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 same window; whereas Shift+click opens 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset